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.
The
graphql-composer
was not able to handle union type return types so when a query/mutation had a union type response (e.g.UpdateAuthorAddressResponse
) while collecting the queries the graphql composer tried to access for example the fieldUpdateAuthorAddressResponse.id
instead ofAuthor.id
which does not exist.So I added a check if the return type is a union type and if this is the case it passes the type name of the fragment to
collectNestedQueries
so that when collecting the nested queries for fragments, it knows the actual field type name.Also in order to correctly build the queries again in the end a new
fragment
property was added to the query node selection so that when building the query for a union type response it wraps the selection with the fragment (e.g.... on Author { ... }
.I added some test cases for this and this solution worked perfectly fine for our use cases so I hope I haven't missed anything.