-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support in DataFetchingFieldSelectionSet for Unions and Interfaces #2079
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
Conversation
…d-to-dfe # Conflicts: # src/main/java/graphql/util/WeakMemoizedSupplier.java
…ield-support # Conflicts: # src/main/java/graphql/util/FpKit.java
|
graphql.schema.DataFetcherSelectionTest still needs to be fixed |
…- this is another one that should die
bbakerman
left a comment
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.
I think this is now ready for review
| protected Supplier<NormalizedField> getNormalizedField(ExecutionContext executionContext, ExecutionStrategyParameters parameters, Supplier<ExecutionStepInfo> executionStepInfo) { | ||
| Supplier<NormalizedQueryTree> normalizedQuery = executionContext.getNormalizedQuery(); | ||
| return () -> normalizedQuery.get().getNormalizedField(parameters.getField(), executionStepInfo.get().getFieldContainer(), executionStepInfo.get().getPath()); | ||
| } |
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.
All made as Supplier to ensure its super lazy - lets not pay any cost unless some one asks for this.
| /** | ||
| * @return a map of the {@link graphql.schema.GraphQLFieldDefinition}s for each field in the selection set | ||
| */ | ||
| Map<String, GraphQLFieldDefinition> getDefinitions(); |
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.
This is part of the breaking changes - these no longer make sense because we have multiple SelectedFields to a named path
| name | ||
| appearsIn | ||
| friends(separationCount : 5) { | ||
| friends { |
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.
This was actually illegal query text - now that we run the whole thing, it needed to be fixed
| DataFetchingFieldSelectionSet selectionSet = null | ||
| DataFetcher humanDF = { DataFetchingEnvironment env -> | ||
| selectionSet = env.getSelectionSet() | ||
| return StarWarsData.humanDataFetcher.get(env) |
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 use side effect to get the inner selection set.
|
|
||
| (selectionSet.definitions['name'].getType() as GraphQLNonNull).getWrappedType() == Scalars.GraphQLString | ||
| (selectionSet.definitions['friends'].getType() as GraphQLList).getWrappedType() == starWarsSchema.getType('Character') | ||
| (selectionSet.definitions['friends/friends'].getType() as GraphQLList).getWrappedType() == starWarsSchema.getType('Character') |
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.
These have been removed and hence so have the tests
|
@bbakerman thanks for improving the PR. Here are some things that are problematic. Overall this has reduced the custom code we need thanks to the ability to find fields with We noticed that the transitive nature of type User {
name: String
address: String
friend: User
}
{
user(id: "steve") {
name
friend {
name
address
}
}
}The selection set for the user query would contain all fields (also the nested ones) and if we try to use the type to tell which fields to take, we end up with [name, friend, address] when what we really want is to be able to tell the two “users” apart and have [name, friend] and later [name, address]. |
|
@bbakerman We've switched to using |
|
@bbakerman @andimarek another friendly ping about this PR. Are there any leftovers or things we can do or help out with in order to get this PR merged? We really need union support in graphql-java 🙏 |
This improves the DataFetchingFieldSelectionSet support so that conditional composite types such as Unions can now be supported.
Its a breaking change because we can now get multiple
SelectedFields in for a given addressing name. ThereforegetFieldno longer makes sense nor do the maps to 1:1 arguments and field definitiionsThis supersedes the PR #1963