-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix serialization of default values for input object enums fix #276
- Loading branch information
Showing
3 changed files
with
142 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/groovy/com/coxautodev/graphql/tools/EnumDefaultValueSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.coxautodev.graphql.tools | ||
|
||
import graphql.GraphQL | ||
import graphql.execution.AsyncExecutionStrategy | ||
import graphql.schema.GraphQLSchema | ||
import spock.lang.Specification | ||
|
||
class EnumDefaultValueSpec extends Specification { | ||
|
||
def "enumvalue is not passed down to graphql-java"() { | ||
when: | ||
GraphQLSchema schema = SchemaParser.newParser().schemaString('''\ | ||
type Query { | ||
test(input: MySortSpecifier): SortBy | ||
} | ||
input MySortSpecifier { | ||
sortBy: SortBy = createdOn | ||
value: Int = 10 | ||
} | ||
enum SortBy { | ||
createdOn | ||
updatedOn | ||
} | ||
''').resolvers(new GraphQLQueryResolver() { | ||
|
||
SortBy test(MySortSpecifier input) { | ||
return input.sortBy | ||
} | ||
|
||
}) | ||
.build() | ||
.makeExecutableSchema() | ||
GraphQL gql = GraphQL.newGraphQL(schema) | ||
.queryExecutionStrategy(new AsyncExecutionStrategy()) | ||
.build() | ||
def data = Utils.assertNoGraphQlErrors(gql, [input: [value: 1]]) { | ||
''' | ||
query test($input: MySortSpecifier) { | ||
test(input: $input) | ||
} | ||
''' | ||
} | ||
|
||
then: | ||
noExceptionThrown() | ||
data.test == 'createdOn' | ||
} | ||
|
||
static class MySortSpecifier { | ||
SortBy sortBy | ||
int value | ||
} | ||
|
||
enum SortBy { | ||
createdOn, | ||
updatedOn | ||
} | ||
|
||
} |
Oops, something went wrong.