File tree Expand file tree Collapse file tree 1 file changed +76
-0
lines changed
src/test/groovy/com/coxautodev/graphql/tools Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments