-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathIssue2274.groovy
More file actions
110 lines (88 loc) · 2.89 KB
/
Issue2274.groovy
File metadata and controls
110 lines (88 loc) · 2.89 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
package graphql
import graphql.language.AstComparator
import graphql.language.Node
import graphql.language.ObjectTypeExtensionDefinition
import graphql.language.TypeName
import graphql.parser.Parser
import spock.lang.Specification
class Issue2274 extends Specification {
boolean isEqual(Node node1, Node node2) {
return new AstComparator().isEqual(node1, node2)
}
// This test happened to work previously, as there were no tokens following 'implements Thing'
def "extend type without text following works - schema build"() {
given:
def spec = '''
type Query {
blob : Blob
}
type Blob {
id: ID!
name: String
}
interface Thing {
name: String
}
input Interval {
now : Int
then : Int
}
# random input
input AwesomeInput {
interval: Interval!
amount: Int!
}
extend type Blob implements Thing
'''
when:
def schema = TestUtil.schema(spec)
then:
schema != null
}
// Placing an input immediately after extend type without braces previously failed
// The schema could not be compiled : SchemaProblem{errors=[The interface type 'input' is not present when resolving type
// 'Blob' [@20:13], The interface type 'AwesomeInput' is not present when resolving type 'Blob' [@20:13]]}. Expression: false
def "extend type with text following works - schema build"() {
given:
def spec = '''
type Query {
blob : Blob
}
type Blob {
id: ID!
name: String
}
interface Thing {
name: String
}
input Interval {
now : Int
then : Int
}
extend type Blob implements Thing
# random input
input AwesomeInput {
interval: Interval!
amount: Int!
}
'''
when:
def schema = TestUtil.schema(spec)
then:
schema != null
}
def "extend type with text following works - parser check"() {
given:
def spec = "extend type Blob implements Thing1 & Thing2 & Thing3"
and: "expected schema"
def objSchema = ObjectTypeExtensionDefinition.newObjectTypeExtensionDefinition().name("Blob")
objSchema.implementz(new TypeName("Thing1"))
objSchema.implementz(new TypeName("Thing2"))
objSchema.implementz(new TypeName("Thing3"))
when:
def document = new Parser().parseDocument(spec)
then:
document.definitions.size() == 1
isEqual(document.definitions[0], objSchema.build())
}
}