TypeError when spreading a fragment on a field of a different type #7364
Labels
core
Related to codegen core/cli
stage/6-released
The issue has been solved on a released version of the library
Describe the bug
This seems likely to be related to #6874.
We have many union types in our schema, especially to define different groups of identity types (e.g. users, admins, or system users). It is technically valid GraphQL to define a fragment on one of these union types and spread it on a field that is a different union type, as long as the individual members of the union are compatible.
This worked without issue when using
core@1.17.10
withvisitor-plugin-common@1.21.1
. After upgrading tocore@2.4.0
andvisitor-plugin-common@2.5.2
aTypeError
is thrown (we are using thenear-operation-file-preset
, if relevant).To Reproduce
Here's a code sandbox demonstrating the issue. I did my best to reduce the issue to the smallest reproduction possible.
https://codesandbox.io/s/silly-pateu-6dzgf?file=/src/document.gql
codegen.yml
config file:Expected behavior
The code generation should succeed, or at a minimum should fail to validate if it's determined that this is invalid GraphQL (our server and previous version of
graphql-codegen
have been fine with this syntax historically).Actual behavior
The text was updated successfully, but these errors were encountered: