graphql-code-generator can be configured to watch for changes in .graphql/.gql schema files and automatically generate Types and Hooks, to be used in a React+Typescript environment. It is described by this article.
Graphql Queries/Mutations/Subscriptions can be defined inside a folder. Codegenerator then uses these definitions to build custom React hooks that map the exact shape of the query. The hook generated has the whole query definition inside a gql literal string tag.
The issue starts when Apollo Plugin attempts to parse this generated query. Since the project already have another query with the same name, as it was copied directly from the original definition, The Apollo Plugin crashes due to repeated query names.
Solution:
Add the option to ignore files matching a certain pattern (Eg: src/__auto_generated__/**, src/hooks/GeneratedHooks/**).
Problem:
graphql-code-generator can be configured to watch for changes in
.graphql
/.gql
schema files and automatically generate Types and Hooks, to be used in a React+Typescript environment. It is described by this article.Graphql Queries/Mutations/Subscriptions can be defined inside a folder. Codegenerator then uses these definitions to build custom React hooks that map the exact shape of the query. The hook generated has the whole query definition inside a
gql
literal string tag.The issue starts when Apollo Plugin attempts to parse this generated query. Since the project already have another query with the same name, as it was copied directly from the original definition, The Apollo Plugin crashes due to repeated query names.
Solution:
Add the option to ignore files matching a certain pattern (Eg:
src/__auto_generated__/**
,src/hooks/GeneratedHooks/**
).