-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathIssue526.groovy
More file actions
91 lines (72 loc) · 2.14 KB
/
Issue526.groovy
File metadata and controls
91 lines (72 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package graphql
import graphql.schema.DataFetcher
import graphql.schema.DataFetchingEnvironment
import spock.lang.Specification
import static graphql.ExecutionInput.newExecutionInput
import static graphql.schema.idl.RuntimeWiring.newRuntimeWiring
import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring
class Issue526 extends Specification {
enum Episode {
NEWHOPE, EMPIRE, JEDI
}
class Droid {
List<Episode> appearsIn = [Episode.NEWHOPE, Episode.EMPIRE]
List<Episode> getAppearsIn() {
return appearsIn
}
Episode getEpisode() {
return Episode.NEWHOPE
}
String getName() {
return "C3PO"
}
}
def "526 - Java enums can match string generated versions of them"() {
given:
def spec = """
enum Episode {
NEWHOPE,
EMPIRE,
JEDI
}
type Droid {
name: String,
episode : Episode,
appearsIn: [Episode],
}
type Query {
droid : Droid
}
"""
def graphQL = TestUtil.graphQL(spec, newRuntimeWiring()
.type(newTypeWiring("Query").dataFetcher("droid", new DataFetcher() {
@Override
Object get(DataFetchingEnvironment environment) {
return new Droid()
}
}))).build()
def query = """
{
droid {
name
episode
appearsIn
}
}
"""
def executionInput = newExecutionInput().query(query).build()
when:
def executionResult = graphQL.execute(executionInput)
then:
executionResult.errors.size() == 0
executionResult.data == [
droid: [
name : "C3PO",
episode : "NEWHOPE",
appearsIn: [
"NEWHOPE", "EMPIRE"
],
]
]
}
}