-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathIssue2055.groovy
More file actions
116 lines (88 loc) · 4.41 KB
/
Issue2055.groovy
File metadata and controls
116 lines (88 loc) · 4.41 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package graphql
import graphql.introspection.Introspection
import graphql.schema.GraphQLEnumType
import graphql.schema.GraphQLNamedInputType
import graphql.schema.GraphQLScalarType
import spock.lang.Specification
class Issue2055 extends Specification {
def "issues 2055 for directive on SCALAR"() {
given:
def dsl = '''
directive @testDirective(aDate: Date) on OBJECT | SCALAR
directive @DummyDirective on SCALAR
scalar Date @DummyDirective
type Query {
aQuery: String
}
'''
when:
def schema = TestUtil.schema(dsl)
then:
schema.getType("Date") != null
schema.getType("Date") instanceof GraphQLScalarType
((GraphQLScalarType) schema.getType("Date")).getDirective("DummyDirective") != null
schema.getDirective("DummyDirective") != null
schema.getDirective("DummyDirective").validLocations().size() == 1
schema.getDirective("DummyDirective").validLocations().asList() == [Introspection.DirectiveLocation.SCALAR]
schema.getDirective("testDirective") != null
schema.getDirective("testDirective").validLocations().size() == 2
schema.getDirective("testDirective").validLocations().asList() == [Introspection.DirectiveLocation.SCALAR, Introspection.DirectiveLocation.OBJECT]
((GraphQLNamedInputType) schema.getDirective("testDirective").getArgument("aDate").getType()).getName() == "Date"
}
def "issues 2055 for directive on ENUM"() {
given:
def dsl = '''
directive @testDirective(anEnum: Episode = JEDI) on OBJECT | ENUM
directive @DummyDirective on ENUM
enum Episode @DummyDirective{
JEDI
NEWHOPE
}
type Query {
aQuery: String
}
'''
when:
def schema = TestUtil.schema(dsl)
then:
schema.getType("Episode") != null
schema.getType("Episode") instanceof GraphQLEnumType
((GraphQLEnumType) schema.getType("Episode")).getValues().size() == 2
((GraphQLEnumType) schema.getType("Episode")).getDirective("DummyDirective").getName() == "DummyDirective"
schema.getDirective("DummyDirective") != null
schema.getDirective("DummyDirective").validLocations().size() == 1
schema.getDirective("DummyDirective").validLocations().asList() == [Introspection.DirectiveLocation.ENUM]
schema.getDirective("testDirective") != null
schema.getDirective("testDirective").validLocations().size() == 2
schema.getDirective("testDirective").validLocations().asList() == [Introspection.DirectiveLocation.OBJECT, Introspection.DirectiveLocation.ENUM]
((GraphQLNamedInputType) schema.getDirective("testDirective").getArgument("anEnum").getType()).getName() == "Episode"
}
def "issues 2055 for directive on ENUM_VALUE"() {
given:
def dsl = '''
directive @testDirective(anEnum: Episode = JEDI) on OBJECT | ENUM_VALUE
directive @DummyDirective on ENUM_VALUE
enum Episode {
JEDI @DummyDirective
NEWHOPE
}
type Query {
aQuery: String
}
'''
when:
def schema = TestUtil.schema(dsl)
then:
schema.getType("Episode") != null
schema.getType("Episode") instanceof GraphQLEnumType
((GraphQLEnumType) schema.getType("Episode")).getValues().size() == 2
((GraphQLEnumType) schema.getType("Episode")).getValue("JEDI").getDirective("DummyDirective").getName() == "DummyDirective"
schema.getDirective("DummyDirective") != null
schema.getDirective("DummyDirective").validLocations().size() == 1
schema.getDirective("DummyDirective").validLocations().asList() == [Introspection.DirectiveLocation.ENUM_VALUE]
schema.getDirective("testDirective") != null
schema.getDirective("testDirective").validLocations().size() == 2
schema.getDirective("testDirective").validLocations().asList() == [Introspection.DirectiveLocation.OBJECT, Introspection.DirectiveLocation.ENUM_VALUE]
((GraphQLNamedInputType) schema.getDirective("testDirective").getArgument("anEnum").getType()).getName() == "Episode"
}
}