-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathIssue1559.groovy
More file actions
90 lines (78 loc) · 3.48 KB
/
Issue1559.groovy
File metadata and controls
90 lines (78 loc) · 3.48 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
package graphql
import graphql.execution.DataFetcherResult
import graphql.schema.DataFetcher
import graphql.schema.DataFetchingEnvironment
import graphql.schema.idl.RuntimeWiring
import graphql.schema.idl.TypeRuntimeWiring
import graphql.validation.ValidationError
import graphql.validation.ValidationErrorType
import spock.lang.Specification
class Issue1559 extends Specification {
def graphql = TestUtil.graphQL("""
type Query {
contextAwareList: [ContextAwareEntity!]!
}
type ContextAwareEntity {
name: String
contextInfo: String
}
""",
RuntimeWiring.newRuntimeWiring()
.type("ContextAwareEntity", {
it.dataFetcher("contextInfo", { it.getLocalContext() })
})
.build())
.build()
def "#1559 test if a list of DataFetcherResults is processed properly"() {
when:
def input = ExecutionInput.newExecutionInput()
.root([contextAwareList: [
DataFetcherResult.newResult().localContext("the context 1").data([name: "the name 1"]).build(),
DataFetcherResult.newResult().localContext("the context 2").data([name: "the name 2"]).build(),
DataFetcherResult.newResult().localContext("the context 3").data([name: "the name 3"]).build(),
DataFetcherResult.newResult().localContext("the context 4").data([name: "the name 4"]).build(),
]])
.query('''
query getTheList {
contextAwareList {
name
contextInfo
}
}
''')
.build()
def executionResult = graphql.execute(input)
then:
executionResult.errors.isEmpty()
executionResult.data == [ contextAwareList: [
[name: "the name 1", contextInfo: "the context 1"],
[name: "the name 2", contextInfo: "the context 2"],
[name: "the name 3", contextInfo: "the context 3"],
[name: "the name 4", contextInfo: "the context 4"],
]]
}
def "#1559 test if null validations are processed properly on DataFetcherResult List"() {
when:
def input = ExecutionInput.newExecutionInput()
.root([contextAwareList: [
DataFetcherResult.newResult().localContext("the context 1").data([name: "the name 1"]).build(),
DataFetcherResult.newResult().localContext("the context 2").data(null).build(),
null,
DataFetcherResult.newResult().localContext("the context 4").data([name: "the name 4"]).build(),
]])
.query('''
query getTheList {
contextAwareList {
name
contextInfo
}
}
''')
.build()
def executionResult = graphql.execute(input)
then:
executionResult.errors.size() == 2
executionResult.errors[0].path == ['contextAwareList', 1]
executionResult.errors[1].path == ['contextAwareList', 2]
}
}