Add supports for Type extention ("extend type" syntax) #17
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.
What
Add supports for Type extention ("extend type" syntax)
Why
In GraphQL, we can extend a type using the "extend type" syntax, like the following example:
Type "Item" contains two attributes "title" and "price".
When generating a GraphQL query with graphql-autotest from the above schema,
the "price" attribute is not output.
In GraphQL-Ruby, an "extend type" block is treated as an independent instance of ObjectTypeExtension class.
It means that multiple definitions with the same name are included in Document#definitions.
On the other hand, QueryGenerator#type_definition assumes that there is only one definition that matches the name, so the definition inside the "extend type" block is not considered.
Example
How to fix
Changed QueryGenerator#type_definition to merge all definitions that matched name.
This change made graphql-autotest work as I expected, but I'm not sure it's the correct change.
For example, I'm worried about the following case expression:
graphql-autotest/lib/graphql/autotest/query_generator.rb
Lines 50 to 69 in d1d534d
--
takeyoda