Skip to content

Commit 158c48d

Browse files
bbakermanandimarek
authored andcommitted
This is the test ported into groovy - it is indeed failing
1 parent 89ef2ce commit 158c48d

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package graphql
2+
3+
import graphql.schema.GraphQLObjectType
4+
import graphql.schema.idl.RuntimeWiring
5+
import spock.lang.Specification
6+
7+
import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring
8+
9+
class Issue739 extends Specification {
10+
11+
def "#739 test"() {
12+
13+
when:
14+
15+
RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring()
16+
.type(newTypeWiring("Query")
17+
.dataFetcher("foo",
18+
{ env ->
19+
Map<String, Object> map = new HashMap<>();
20+
map.put("id", "abc")
21+
return map;
22+
23+
})
24+
.dataFetcher("bar",
25+
{ env ->
26+
Map<String, Object> map = new HashMap<>();
27+
map.put("id", "def")
28+
return map;
29+
})
30+
)
31+
.type(newTypeWiring("Node")
32+
.typeResolver({ env -> (GraphQLObjectType) env.getSchema().getType("Foo") }))
33+
.build()
34+
35+
36+
def schema = TestUtil.schema("""
37+
schema {
38+
query: Query
39+
}
40+
41+
type Query {
42+
foo: Node
43+
bar(input: BarInput!): Node
44+
}
45+
46+
input BarInput {
47+
baz: String!
48+
}
49+
50+
interface Node {
51+
id: String
52+
}
53+
54+
type Foo implements Node {
55+
id: String
56+
}
57+
""", runtimeWiring)
58+
59+
60+
GraphQL graphQL = GraphQL.newGraphQL(schema)
61+
.build()
62+
63+
ExecutionInput noVarInput = ExecutionInput.newExecutionInput()
64+
.query('{ bar(input: 123) { id } } ')
65+
.build()
66+
67+
ExecutionResult noVarResult = graphQL
68+
.executeAsync(noVarInput)
69+
.join()
70+
71+
then:
72+
73+
1 == noVarResult.getErrors().size()
74+
75+
when:
76+
def variables = ["input": 123]
77+
78+
ExecutionInput varInput = ExecutionInput.newExecutionInput()
79+
.query('query Bar($input: BarInput!) {bar(input: $input) {id}}')
80+
.variables(variables)
81+
.build();
82+
83+
ExecutionResult varResult = graphQL
84+
.executeAsync(varInput)
85+
.join()
86+
87+
then:
88+
1 == varResult.getErrors().size()
89+
}
90+
}

0 commit comments

Comments
 (0)