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
{{ message }}
Repository navigation
Commit 43d849e
Browse filesBrowse the repository at this point in the historyBrowse files
"item" to "Resolver method '${PlainFutureQuery::class.java.name}.item' resolved to a java.util.concurrent.FutureTask, "+
62
+
"which graphql-java can't wait on. Return a CompletionStage, such as a CompletableFuture, from the method or its generic wrapper transformer instead.",
63
+
"itemWithArgument" to "Resolver method '${PlainFutureQuery::class.java.name}.itemWithArgument' resolved to a java.util.concurrent.FutureTask, "+
64
+
"which graphql-java can't wait on. Return a CompletionStage, such as a CompletableFuture, from the method or its generic wrapper transformer instead.",
65
+
"name" to "Resolver method '${PlainFutureQuery::class.java.name}.name' resolved to a java.util.concurrent.FutureTask, "+
66
+
"which graphql-java can't wait on. Return a CompletionStage, such as a CompletableFuture, from the method or its generic wrapper transformer instead."
67
+
))
55
68
}
56
69
57
70
@Test
58
71
fun`suspend function that resolves to a future fails with a clear error`() {
59
-
val result =GraphQL.newGraphQL(itemSchema(PlainFutureQuery())).build()
60
-
.execute("query { suspendItem { id } suspendCompletableItem { id } }")
72
+
val gql =GraphQL.newGraphQL(itemSchema(PlainFutureQuery())).build()
73
+
74
+
val result = gql.execute(
75
+
"""
76
+
query {
77
+
suspendItem { id }
78
+
suspendCompletableItem { id }
79
+
}
80
+
""")
61
81
62
82
assertEquals(result.getData(), mapOf("suspendItem" to null, "suspendCompletableItem" to null))
63
83
assertEquals(result.errorMessagesByPath(), mapOf(
64
-
"suspendItem" to FutureTask::class.java,
65
-
"suspendCompletableItem" to CompletableFuture::class.java
66
-
).mapValues { (name, futureClass) ->
67
-
"Suspend function '${PlainFutureQuery::class.java.name}.$name' resolved to a ${futureClass.name}, which graphql-java can't wait on. Return its value instead."
68
-
})
84
+
"suspendItem" to "Suspend function '${PlainFutureQuery::class.java.name}.suspendItem' resolved to a java.util.concurrent.FutureTask, "+
85
+
"which graphql-java can't wait on. Return its value instead.",
86
+
"suspendCompletableItem" to "Suspend function '${PlainFutureQuery::class.java.name}.suspendCompletableItem' resolved to a java.util.concurrent.CompletableFuture, "+
87
+
"which graphql-java can't wait on. Return its value instead."
88
+
))
69
89
}
70
90
71
91
@Test
@@ -76,7 +96,15 @@ class ReactiveTest {
76
96
val gql =GraphQL.newGraphQL(itemSchema(PlainFutureQuery(), options)).build()
77
97
78
98
val data = assertNoGraphQlErrors(gql) {
79
-
"query { item { id } itemWithArgument(id: 2) { id } name suspendItem { id } nullItem { id } }"
99
+
"""
100
+
query {
101
+
item { id }
102
+
itemWithArgument(id: 2) { id }
103
+
name
104
+
suspendItem { id }
105
+
nullItem { id }
106
+
}
107
+
"""
80
108
}
81
109
82
110
assertEquals(data, mapOf(
@@ -111,14 +139,27 @@ class ReactiveTest {
111
139
.build())
112
140
.build()
113
141
.makeExecutableSchema()
142
+
val gql =GraphQL.newGraphQL(schema).build()
114
143
115
-
val result =GraphQL.newGraphQL(schema).build().execute("query { item { id } boxedItem { id } search { ... on Item { id } } }")
144
+
val result = gql.execute(
145
+
"""
146
+
query {
147
+
item { id }
148
+
boxedItem { id }
149
+
search {
150
+
... on Item { id }
151
+
}
152
+
}
153
+
""")
116
154
117
155
assertEquals(result.getData(), mapOf("item" to null, "boxedItem" to null, "search" to null))
118
156
assertEquals(result.errorMessagesByPath(), mapOf(
119
-
"item" to plainFutureError(ItemQuery::class.java, "item"),
120
-
"boxedItem" to plainFutureError(FutureItemQuery::class.java, "boxedItem"),
121
-
"search" to plainFutureError(FutureItemQuery::class.java, "search")
157
+
"item" to "Resolver method '${ItemQuery::class.java.name}.item' resolved to a java.util.concurrent.FutureTask, "+
158
+
"which graphql-java can't wait on. Return a CompletionStage, such as a CompletableFuture, from the method or its generic wrapper transformer instead.",
159
+
"boxedItem" to "Resolver method '${FutureItemQuery::class.java.name}.boxedItem' resolved to a java.util.concurrent.FutureTask, "+
160
+
"which graphql-java can't wait on. Return a CompletionStage, such as a CompletableFuture, from the method or its generic wrapper transformer instead.",
161
+
"search" to "Resolver method '${FutureItemQuery::class.java.name}.search' resolved to a java.util.concurrent.FutureTask, "+
162
+
"which graphql-java can't wait on. Return a CompletionStage, such as a CompletableFuture, from the method or its generic wrapper transformer instead."
122
163
))
123
164
}
124
165
@@ -144,41 +185,16 @@ class ReactiveTest {
144
185
val gql =GraphQL.newGraphQL(schema).build()
145
186
146
187
val data = assertNoGraphQlErrors(gql) {
147
-
"query { job { id } }"
188
+
"""
189
+
query {
190
+
job { id }
191
+
}
192
+
"""
148
193
}
149
194
150
195
assertEquals(data, mapOf("job" to mapOf("id" to "1")))
151
196
}
152
197
153
-
@Test
154
-
fun`future resolves as a value when no generic wrapper unwraps it`() {
0 commit comments