-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added in local context to TypeResolutionEnvironment #2699
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
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -20,33 +20,24 @@ | |
| public class ResolveType { | ||
|
|
||
|
|
||
| public GraphQLObjectType resolveType(ExecutionContext executionContext, MergedField field, Object source, ExecutionStepInfo executionStepInfo, GraphQLType fieldType) { | ||
| public GraphQLObjectType resolveType(ExecutionContext executionContext, MergedField field, Object source, ExecutionStepInfo executionStepInfo, GraphQLType fieldType, Object localContext) { | ||
| GraphQLObjectType resolvedType; | ||
| DataFetchingFieldSelectionSet fieldSelectionSet = buildSelectionSet(executionContext, field, (GraphQLOutputType) fieldType, executionStepInfo); | ||
| TypeResolutionEnvironment env = TypeResolutionParameters.newParameters() | ||
| .field(field) | ||
| .fieldType(fieldType) | ||
| .value(source) | ||
| .argumentValues(executionStepInfo.getArguments()) | ||
| .selectionSet(fieldSelectionSet) | ||
| .context(executionContext.getContext()) | ||
| .graphQLContext(executionContext.getGraphQLContext()) | ||
| .localContext(localContext) | ||
| .schema(executionContext.getGraphQLSchema()) | ||
| .build(); | ||
| if (fieldType instanceof GraphQLInterfaceType) { | ||
|
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. Simplified - there was never a need for the union vs interface type - there are never treated special outside this spot and again only for resolver lookup |
||
| DataFetchingFieldSelectionSet fieldSelectionSet = buildSelectionSet(executionContext, field, (GraphQLOutputType) fieldType, executionStepInfo); | ||
| TypeResolutionParameters resolutionParams = TypeResolutionParameters.newParameters() | ||
| .graphQLInterfaceType((GraphQLInterfaceType) fieldType) | ||
| .field(field) | ||
| .value(source) | ||
| .argumentValues(executionStepInfo.getArguments()) | ||
| .selectionSet(fieldSelectionSet) | ||
| .context(executionContext.getContext()) | ||
| .graphQLContext(executionContext.getGraphQLContext()) | ||
| .schema(executionContext.getGraphQLSchema()).build(); | ||
| resolvedType = resolveTypeForInterface(resolutionParams); | ||
|
|
||
| resolvedType = resolveTypeForInterface(env, (GraphQLInterfaceType) fieldType); | ||
| } else if (fieldType instanceof GraphQLUnionType) { | ||
| DataFetchingFieldSelectionSet selectionSet = buildSelectionSet(executionContext, field, (GraphQLOutputType) fieldType, executionStepInfo); | ||
| TypeResolutionParameters resolutionParams = TypeResolutionParameters.newParameters() | ||
| .graphQLUnionType((GraphQLUnionType) fieldType) | ||
| .field(field) | ||
| .value(source) | ||
| .argumentValues(executionStepInfo.getArguments()) | ||
| .selectionSet(selectionSet) | ||
| .context(executionContext.getContext()) | ||
| .graphQLContext(executionContext.getGraphQLContext()) | ||
| .schema(executionContext.getGraphQLSchema()).build(); | ||
| resolvedType = resolveTypeForUnion(resolutionParams); | ||
| resolvedType = resolveTypeForUnion(env, (GraphQLUnionType) fieldType); | ||
| } else { | ||
| resolvedType = (GraphQLObjectType) fieldType; | ||
| } | ||
|
|
@@ -59,28 +50,23 @@ private DataFetchingFieldSelectionSet buildSelectionSet(ExecutionContext executi | |
| return DataFetchingFieldSelectionSetImpl.newCollector(executionContext.getGraphQLSchema(), fieldType, normalizedFieldSupplier); | ||
| } | ||
|
|
||
| public GraphQLObjectType resolveTypeForInterface(TypeResolutionParameters params) { | ||
| TypeResolutionEnvironment env = new TypeResolutionEnvironment(params.getValue(), params.getArgumentValues(), params.getField(), params.getGraphQLInterfaceType(), params.getSchema(), params.getContext(), params.getGraphQLContext(), params.getSelectionSet()); | ||
| GraphQLInterfaceType abstractType = params.getGraphQLInterfaceType(); | ||
| TypeResolver typeResolver = params.getSchema().getCodeRegistry().getTypeResolver(abstractType); | ||
| return resolveAbstractType(params, env, typeResolver, abstractType); | ||
| public GraphQLObjectType resolveTypeForInterface(TypeResolutionEnvironment env, GraphQLInterfaceType abstractType) { | ||
| TypeResolver typeResolver = env.getSchema().getCodeRegistry().getTypeResolver(abstractType); | ||
| return resolveAbstractType(env, typeResolver, abstractType); | ||
| } | ||
|
|
||
| public GraphQLObjectType resolveTypeForUnion(TypeResolutionParameters params) { | ||
| TypeResolutionEnvironment env = new TypeResolutionEnvironment(params.getValue(), params.getArgumentValues(), params.getField(), params.getGraphQLUnionType(), params.getSchema(), params.getContext(), params.getGraphQLContext(), params.getSelectionSet()); | ||
| GraphQLUnionType abstractType = params.getGraphQLUnionType(); | ||
| TypeResolver typeResolver = params.getSchema().getCodeRegistry().getTypeResolver(abstractType); | ||
| return resolveAbstractType(params, env, typeResolver, abstractType); | ||
| public GraphQLObjectType resolveTypeForUnion(TypeResolutionEnvironment env, GraphQLUnionType abstractType) { | ||
| TypeResolver typeResolver = env.getSchema().getCodeRegistry().getTypeResolver(abstractType); | ||
| return resolveAbstractType(env, typeResolver, abstractType); | ||
| } | ||
|
|
||
| private GraphQLObjectType resolveAbstractType(TypeResolutionParameters params, TypeResolutionEnvironment env, TypeResolver typeResolver, GraphQLNamedOutputType abstractType) { | ||
| private GraphQLObjectType resolveAbstractType(TypeResolutionEnvironment env, TypeResolver typeResolver, GraphQLNamedOutputType abstractType) { | ||
| GraphQLObjectType result = typeResolver.getType(env); | ||
|
|
||
| if (result == null) { | ||
| throw new UnresolvedTypeException(abstractType); | ||
| } | ||
|
|
||
| if (!params.getSchema().isPossibleType(abstractType, result)) { | ||
| if (!env.getSchema().isPossibleType(abstractType, result)) { | ||
| throw new UnresolvedTypeException(abstractType, result); | ||
| } | ||
|
|
||
|
|
||
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
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
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.
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.
Yes this is breaking API - but this should not have been made public - a builder pattern (which we started AFTER this class was invented) would have not made this a breaking change.
We really dont want consumers making these
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.
we could got the whole hog and merge the two classes and put the builder int this class. I chose not to do this - progress over perfection