DataFetchingFieldSelectionSet ignores inline fragments when parent type is interface/union #1952
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.
[DO NOT MERGE]
Description
This PR is more of a question than a PR, the code changes consist of a single unit test to reproduce the use case.
Say I have the following shortened SWAPI schema:
and the following query:
{ humanCharacter(id: "1003") { --> returns Leia who is a Human id __typename ... on Human { homePlanet } } }The selection set returned by
environment.getSelectionSet().get().keySet()when ran from theQuery.humanCharacterdata fetcher contains all the fields buthomePlanet. That is:I would like to understand if this omission is by design or it is a defect.
If it is by design:
We are returning only the fields in the selection set which we are sure are of the same type as the field output type. In our example, we would only return the fields from the selection set that are on the type
Character.Assuming it is by design, does it kind of defeats the purpose of looking ahead?
If say, we were making a request to a SQL system (as per the doc) using the
DataDetchingSelectionSetfields as projection. Since we only get back the selected fields onCharacter, i.eidand__typename, wouldn't this create a hurdle ashomePlanetwould be missing from the SQL statement?If it is a defect
I can update the PR to include fragments in the selection set.
The test added in this PR fails because it expected
homePlanetto be included: