Skip to content

Commit 6c31fe8

Browse files
committed
Added unit test to try to reproduce #115
1 parent 65f04e4 commit 6c31fe8

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.coxautodev.graphql.tools
2+
3+
import graphql.GraphQL
4+
import graphql.execution.AsyncExecutionStrategy
5+
import graphql.schema.GraphQLSchema
6+
import spock.lang.Shared
7+
import spock.lang.Specification
8+
9+
class EnumListParameterSpec extends Specification {
10+
11+
@Shared
12+
GraphQL gql
13+
14+
def setupSpec() {
15+
GraphQLSchema schema = SchemaParser.newParser().schemaString('''\
16+
type Query {
17+
countries(regions: [Region!]!): [Country!]!
18+
}
19+
20+
enum Region {
21+
EUROPE
22+
ASIA
23+
}
24+
25+
type Country {
26+
code: String!
27+
name: String!
28+
regions: [Region!]
29+
}
30+
'''.stripIndent())
31+
.resolvers(new QueryResolver())
32+
.build()
33+
.makeExecutableSchema()
34+
gql = GraphQL.newGraphQL(schema)
35+
.queryExecutionStrategy(new AsyncExecutionStrategy())
36+
.build()
37+
}
38+
39+
def "query with parameter type list of enums should resolve correctly"() {
40+
when:
41+
def data = Utils.assertNoGraphQlErrors(gql, [regions: ["EUROPE", "ASIA"]]) {
42+
'''
43+
query getCountries($regions: [Region!]!) {
44+
countries(regions: $regions){
45+
code
46+
name
47+
regions
48+
}
49+
}
50+
'''
51+
}
52+
53+
then:
54+
data.countries == []
55+
}
56+
57+
class QueryResolver implements GraphQLQueryResolver {
58+
Set<Country> getCountries(Set<Region> regions) {
59+
return Collections.emptySet()
60+
}
61+
}
62+
63+
class Country {
64+
String code
65+
String name
66+
List<Region> regions
67+
}
68+
69+
enum Region {
70+
EUROPE,
71+
ASIA
72+
}
73+
74+
}
75+
76+

0 commit comments

Comments
 (0)