11package com.coxautodev.graphql.tools
22
3+ import graphql.GraphQL
4+ import graphql.execution.AsyncExecutionStrategy
5+ import graphql.schema.GraphQLSchema
36import spock.lang.Specification
47
58class NestedInputTypesSpec extends Specification {
69
710 def " nested input types are parsed" () {
811 when :
9- SchemaParser . newParser(). schemaString(''' \
12+ GraphQLSchema schema = SchemaParser . newParser(). schemaString(''' \
1013 type Query {
1114 materials(filter: MaterialFilter): [Material!]!
1215 }
@@ -31,9 +34,23 @@ class NestedInputTypesSpec extends Specification {
3134 }
3235 ''' ). resolvers(new QueryResolver ())
3336 .build()
37+ .makeExecutableSchema()
38+ GraphQL gql = GraphQL . newGraphQL(schema)
39+ .queryExecutionStrategy(new AsyncExecutionStrategy ())
40+ .build()
41+ def data = Utils . assertNoGraphQlErrors(gql, [filter : [title : " title" , requestFilter : [discountTypeFilter : [name : " discount" ]]]]) {
42+ '''
43+ query materials($filter: MaterialFilter!) {
44+ materials(filter: $filter) {
45+ id
46+ }
47+ }
48+ '''
49+ }
3450
3551 then :
3652 noExceptionThrown()
53+ data. materials == []
3754 }
3855
3956 class QueryResolver implements GraphQLQueryResolver {
@@ -44,18 +61,18 @@ class NestedInputTypesSpec extends Specification {
4461 Long id
4562 }
4663
47- class MaterialFilter {
64+ static class MaterialFilter {
4865 String title
4966 RequestFilter requestFilter
5067 }
5168
52- class RequestFilter {
69+ static class RequestFilter {
5370 List<RequestFilter > and
5471 List<RequestFilter > or
5572 DiscountTypeFilter discountTypeFilter
5673 }
5774
58- class DiscountTypeFilter {
75+ static class DiscountTypeFilter {
5976 String name
6077 }
6178}
0 commit comments