apollographql / apollo-tooling

✏️ Apollo CLI for client tooling (Mostly replaced by Rover)
https://apollographql.com
MIT License
3.04k stars 468 forks source link

Add setting for ignoring/excluding a file pattern from #2064

Open VictorGaiva opened 4 years ago

VictorGaiva commented 4 years ago

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/**).

Stormix commented 2 years ago

+1