-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathIssue1768.groovy
More file actions
69 lines (57 loc) · 1.85 KB
/
Issue1768.groovy
File metadata and controls
69 lines (57 loc) · 1.85 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
package graphql
import graphql.schema.DataFetcher
import spock.lang.Specification
class Issue1768 extends Specification {
static enum ThreadSort {
NEWEST_FIRST,
OLDEST_FIRST,
MOST_COMMENTS_FIRST
}
def "#1768 check if the old behavior is not broken" () {
def spec = '''
type Query {
dummy: String
}
'''
GraphQL graphql = TestUtil.graphQL(spec, [Query: [dummy: (DataFetcher<String>) { null }]]).build()
when:
ExecutionResult result = graphql.execute {
it.query(" { dummy } ")
}
then:
result.data.dummy == null
}
def "#1768 test if local context is set for top level"() {
def spec = '''
type Query {
dummy: String
}
'''
GraphQL graphql = TestUtil.graphQL(spec, [Query: [dummy: (DataFetcher<String>) { (String) it.localContext }]]).build()
when:
ExecutionResult result = graphql.execute {
it.localContext("test").query(" { dummy } ")
}
then:
result.data.dummy == "test"
}
def "#1768 test if the top local context gets transferred to the next level"() {
def spec = '''
type Query {
dummy: DummyType
}
type DummyType {
dummy: String
}
'''
GraphQL graphql = TestUtil.graphQL(spec, [
Query: [dummy: (DataFetcher<Map>) { [ : ]}],
DummyType: [dummy: (DataFetcher<String>) { (String) it.localContext }]]).build()
when:
ExecutionResult result = graphql.execute {
it.localContext("test").query(" { dummy { dummy }} ")
}
then:
result.data.dummy.dummy == "test"
}
}