Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Test cleanup: typeResolver builder on unions and interfaces, applied directive tests, and more #2954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Test cleanup: typeResolver builder on unions and interfaces, applied directive tests, and more #2954
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6af2ecd
Update tests to remove deprecated typeResolver builder for unions and…
dondonz 75f78dc
Use DataLoaderFactory builder instead
dondonz a40eab5
Replace staticValue with datafetcher
dondonz 54f7f13
Update directive tests to use applied directives
dondonz bf628ca
Update tests to use correct directive methods
dondonz 0a2f295
Move deprecated argument test
dondonz f5f6b48
Update directive tests
dondonz cf0abe9
Fix more applied directive deprecations, instrumentation deprecations
dondonz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -275,6 +275,13 @@ public Builder extensionDefinitions(List<UnionTypeExtensionDefinition> extension | |
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * @param typeResolver the type resolver | ||
| * | ||
| * @return this builder | ||
| * | ||
| * @deprecated use {@link graphql.schema.GraphQLCodeRegistry.Builder#typeResolver(GraphQLUnionType, TypeResolver)} instead | ||
| */ | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add doc to make the alternative clearer |
||
| @Deprecated | ||
| @DeprecatedAt("2018-12-03") | ||
| public Builder typeResolver(TypeResolver typeResolver) { | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ package graphql | |
|
|
||
| import graphql.analysis.MaxQueryComplexityInstrumentation | ||
| import graphql.analysis.MaxQueryDepthInstrumentation | ||
| import graphql.collect.ImmutableKit | ||
| import graphql.execution.AsyncExecutionStrategy | ||
| import graphql.execution.AsyncSerialExecutionStrategy | ||
| import graphql.execution.DataFetcherExceptionHandler | ||
|
|
@@ -26,7 +25,6 @@ import graphql.schema.DataFetcher | |
| import graphql.schema.DataFetchingEnvironment | ||
| import graphql.schema.FieldCoordinates | ||
| import graphql.schema.GraphQLCodeRegistry | ||
| import graphql.schema.GraphQLDirective | ||
| import graphql.schema.GraphQLEnumType | ||
| import graphql.schema.GraphQLFieldDefinition | ||
| import graphql.schema.GraphQLInterfaceType | ||
|
|
@@ -64,13 +62,19 @@ class GraphQLTest extends Specification { | |
| GraphQLFieldDefinition.Builder fieldDefinition = newFieldDefinition() | ||
| .name("hello") | ||
| .type(GraphQLString) | ||
| .staticValue("world") | ||
| GraphQLSchema schema = newSchema().query( | ||
| newObject() | ||
| FieldCoordinates fieldCoordinates = FieldCoordinates.coordinates("RootQueryType", "hello") | ||
| DataFetcher<?> dataFetcher = { env -> "world" } | ||
| GraphQLCodeRegistry codeRegistry = GraphQLCodeRegistry.newCodeRegistry() | ||
| .dataFetcher(fieldCoordinates, dataFetcher) | ||
| .build() | ||
|
|
||
| GraphQLSchema schema = newSchema() | ||
| .codeRegistry(codeRegistry) | ||
| .query(newObject() | ||
| .name("RootQueryType") | ||
| .field(fieldDefinition) | ||
| .build() | ||
| ).build() | ||
| .build()) | ||
| .build() | ||
| schema | ||
| } | ||
|
|
||
|
|
@@ -83,7 +87,6 @@ class GraphQLTest extends Specification { | |
|
|
||
| then: | ||
| result == [hello: 'world'] | ||
|
|
||
| } | ||
|
|
||
| def "query with sub-fields"() { | ||
|
|
@@ -103,14 +106,20 @@ class GraphQLTest extends Specification { | |
| GraphQLFieldDefinition.Builder simpsonField = newFieldDefinition() | ||
| .name("simpson") | ||
| .type(heroType) | ||
| .staticValue([id: '123', name: 'homer']) | ||
|
|
||
| GraphQLSchema graphQLSchema = newSchema().query( | ||
| newObject() | ||
| FieldCoordinates fieldCoordinates = FieldCoordinates.coordinates("RootQueryType", "simpson") | ||
| DataFetcher<?> dataFetcher = { env -> [id: '123', name: 'homer'] } | ||
| GraphQLCodeRegistry codeRegistry = GraphQLCodeRegistry.newCodeRegistry() | ||
| .dataFetcher(fieldCoordinates, dataFetcher) | ||
| .build() | ||
|
|
||
| GraphQLSchema graphQLSchema = newSchema() | ||
| .codeRegistry(codeRegistry) | ||
| .query(newObject() | ||
| .name("RootQueryType") | ||
| .field(simpsonField) | ||
| .build() | ||
| ).build() | ||
| .build()) | ||
| .build() | ||
|
|
||
| when: | ||
| def result = GraphQL.newGraphQL(graphQLSchema).build().execute('{ simpson { id, name } }').data | ||
|
|
@@ -125,13 +134,20 @@ class GraphQLTest extends Specification { | |
| .name("hello") | ||
| .type(GraphQLString) | ||
| .argument(newArgument().name("arg").type(GraphQLString)) | ||
| .staticValue("world") | ||
| GraphQLSchema schema = newSchema().query( | ||
| newObject() | ||
|
|
||
| FieldCoordinates fieldCoordinates = FieldCoordinates.coordinates("RootQueryType", "hello") | ||
| DataFetcher<?> dataFetcher = { env -> "hello" } | ||
| GraphQLCodeRegistry codeRegistry = GraphQLCodeRegistry.newCodeRegistry() | ||
| .dataFetcher(fieldCoordinates, dataFetcher) | ||
| .build() | ||
|
|
||
| GraphQLSchema schema = newSchema() | ||
| .codeRegistry(codeRegistry) | ||
| .query(newObject() | ||
| .name("RootQueryType") | ||
| .field(fieldDefinition) | ||
| .build() | ||
| ).build() | ||
| .build()) | ||
| .build() | ||
|
|
||
| when: | ||
| def errors = GraphQL.newGraphQL(schema).build().execute('{ hello(arg:11) }').errors | ||
|
|
@@ -696,7 +712,6 @@ class GraphQLTest extends Specification { | |
|
|
||
| } | ||
|
|
||
|
|
||
| def "execution input passing builder"() { | ||
| given: | ||
| GraphQLSchema schema = simpleSchema() | ||
|
|
@@ -714,7 +729,6 @@ class GraphQLTest extends Specification { | |
| GraphQLSchema schema = simpleSchema() | ||
|
|
||
| when: | ||
|
|
||
| def builderFunction = { it.query('{hello}') } as UnaryOperator<Builder> | ||
| def result = GraphQL.newGraphQL(schema).build().execute(builderFunction).data | ||
|
|
||
|
|
@@ -856,7 +870,6 @@ class GraphQLTest extends Specification { | |
| .name("id") | ||
| .type(Scalars.GraphQLID) | ||
| } as UnaryOperator) | ||
| .typeResolver({ type -> foo }) | ||
| .build() | ||
|
|
||
| GraphQLObjectType query = newObject() | ||
|
|
@@ -869,7 +882,12 @@ class GraphQLTest extends Specification { | |
| } as UnaryOperator) | ||
| .build() | ||
|
|
||
| def codeRegistry = GraphQLCodeRegistry.newCodeRegistry() | ||
| .typeResolver(node, {type -> foo }) | ||
| .build() | ||
|
|
||
| GraphQLSchema schema = newSchema() | ||
| .codeRegistry(codeRegistry) | ||
| .query(query) | ||
| .build() | ||
|
|
||
|
|
@@ -1397,28 +1415,6 @@ many lines'''] | |
| e.message.contains("an illegal value for the argument ") | ||
| } | ||
|
|
||
| def "Applied schema directives arguments are validated for programmatic schemas"() { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to another file |
||
| given: | ||
| def arg = newArgument().name("arg").type(GraphQLInt).valueProgrammatic(ImmutableKit.emptyMap()).build() | ||
| def directive = GraphQLDirective.newDirective().name("cached").argument(arg).build() | ||
| def field = newFieldDefinition() | ||
| .name("hello") | ||
| .type(GraphQLString) | ||
| .argument(arg) | ||
| .withDirective(directive) | ||
| .build() | ||
| when: | ||
| newSchema().query( | ||
| newObject() | ||
| .name("Query") | ||
| .field(field) | ||
| .build()) | ||
| .build() | ||
| then: | ||
| def e = thrown(InvalidSchemaException) | ||
| e.message.contains("Invalid argument 'arg' for applied directive of name 'cached'") | ||
| } | ||
|
|
||
| def "getters work as expected"() { | ||
| Instrumentation instrumentation = new SimpleInstrumentation() | ||
| when: | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You can’t perform that action at this time.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add doc to make the alternative clearer