File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
example/src/main/kotlin/com.expedia.graphql.sample Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import com.expedia.graphql.annotations.GraphQLIgnore
66@GraphQLDescription(" A useful widget" )
77data class Widget (
88 @property:GraphQLDescription("The widget's value that can be null")
9- val value : Int? ,
9+ var value : Int? = null ,
1010 @property:Deprecated(message = "This field is deprecated", replaceWith = ReplaceWith ("value"))
1111 @property:GraphQLDescription("The widget's deprecated value that shouldn't be used")
1212 val deprecatedValue : Int? = value,
Original file line number Diff line number Diff line change 1+ package com.expedia.graphql.sample.mutation
2+
3+ import com.expedia.graphql.annotations.GraphQLDescription
4+ import com.expedia.graphql.sample.model.Widget
5+ import org.springframework.stereotype.Component
6+
7+ /* *
8+ * Simple widget mutation that shows that same objects can be used for input and output GraphQL types.
9+ */
10+ @Component
11+ class WidgetMutation : Mutation {
12+
13+ @GraphQLDescription(" modifies passed in widget so it doesn't have null value" )
14+ fun processWidget (@GraphQLDescription(" widget to be modified" ) widget : Widget ): Widget {
15+ if (null == widget.value) {
16+ widget.value = 42
17+ }
18+ return widget
19+ }
20+ }
Original file line number Diff line number Diff line change @@ -46,4 +46,10 @@ class SimpleQuery: Query {
4646 val random = Random ()
4747 return (1 .. 10 ).map { random.nextInt(100 ) }.toList()
4848 }
49+
50+ @GraphQLDescription(" query with optional input" )
51+ fun doSomethingWithOptionalInput (
52+ @GraphQLDescription(" this field is required" ) requiredValue : Int ,
53+ @GraphQLDescription(" this field is optional" ) optionalValue : Int? = null)
54+ = " required value=$requiredValue , optional value=$optionalValue "
4955}
You can’t perform that action at this time.
0 commit comments