Excluding Fields
There are two ways to ensure the GraphQL schema generation omits fields when using Kotlin reflection:
- The first is by marking the field as non-
publicscope (private,protected,internal) - The second method is by annotating the field with
@GraphQLIgnore.
class SimpleQuery {
@GraphQLIgnore
fun notPartOfSchema() = "ignore me!"
private fun privateFunctionsAreNotVisible() = "ignored private function"
fun doSomething(value: Int): Boolean = true
}
The above query would produce the following GraphQL schema:
type Query {
doSomething(value: Int!): Boolean!
}
Note that the public method notPartOfSchema is not included in the schema.