You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-16Lines changed: 46 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,17 +187,17 @@ TBD
187
187
188
188
All GraphQL servers have a concept of a "context". A GraphQL context contains metadata that is useful to the GraphQL server, but shouldn't necessarily be part of the GraphQL query's API. A prime example of something that is appropriate for the GraphQL context would be trace headers for an OpenTracing system such as Zipkin or Haystack. The GraphQL query itself does not need the information to perform its function, but the server itself needs the information to ensure observability.
189
189
190
-
The contents of the GraphQL context vary across GraphQL applications. For JVM based applications, `graphql-java` provides a `GraphQLContext` interface that can be extended.
190
+
The contents of the GraphQL context vary across GraphQL applications. For JVM based applications, `graphql-java` provides a context interface that can be extended.
191
191
192
192
Simply add `@GraphQLContext` to any argument to a field, and the GraphQL context for the environment will be injected. These arguments will be omitted by the schema generator.
@property:GraphQLDescription("The widget's value that can be null")
261
+
val value: Int?
262
262
)
263
263
264
264
class Query {
265
265
@GraphQLDescription("Does something very special")
266
266
fundoSomething(
267
-
@GraphQLDescription("The special ingredient") value: Int
268
-
): Widget! {
269
-
returnWidget(value !== 1)
267
+
@GraphQLDescription("The special ingredient") value: Int?
268
+
): Widget {
269
+
returnWidget(value)
270
270
}
271
271
}
272
272
```
@@ -280,21 +280,51 @@ schema {
280
280
281
281
# A useful widget
282
282
typeWidget {
283
-
# The widget's value
284
-
value: Boolean
283
+
# The widget's value that can be null
284
+
value: Int
285
285
}
286
286
287
287
typeTopLevelQuery {
288
288
# Does something very useful
289
289
doSomething(
290
290
# The special ingredient
291
-
value: Int!
292
-
): Boolean!
291
+
value: Int
292
+
): Widget!
293
293
}
294
294
```
295
295
296
296
Notethatthedataclasspropertyisannotatedas `@property:GraphQLDescription`. Thisisduetothewaykotlin [mapsbacktothejavaelements](https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets). If you do not add the `property` prefix the annotation is actually on the contructor argument and will not be picked up by the generator.
297
297
298
+
299
+
### `@Deprecated`
300
+
301
+
GraphQLschemascanhavefieldsmarkedasdeprecated. Insteadofcreatingacustomannotation, `graphql-kotlin` just looks for the `kotlin.Deprecated` annotation and will use the message for the deprecated reason.
302
+
303
+
```
304
+
class Query {
305
+
@Deprecated("Do not use this anymore")
306
+
valrestApi = "example.com/api"
307
+
308
+
valgraphQLApi = "example.com/graphql"
309
+
}
310
+
```
311
+
312
+
The above query would produce the following GraphQL schema:
0 commit comments