dotansimha / dotansimha/graphql-code-generator

DocumentNode variable name collisions with typed-document-node and typescript-react-apollo Plugins

Open
#5,333 13 comments 18 reactions 0 assignees View on GitHub
kind/enhancement plugins
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

**Describe the bug**
When using both the `typed-document-node` and `typescript-react-apollo` plugins, the DocumentNodes get generated for both plugin, and results in a variable name collision.

**Reproduction**
https://codesandbox.io/s/strange-mestorf-vre8l?file=/types.ts

**Additional context**
I only have one example in the codesandbox reproduction above, but received slightly different behavior regardless of the config setup.

It also appears possible to generate the TypedDocumentNodes in a separate file, and import them for use by the typescript-react-apollo, but this would be sub-optimal because we already export both document nodes and hooks from our single generated file in many spots in our project.

I'm not sure it is possible to automatically detect this plugin collision or if that is even within either's scope, but adding another documentMode option to the typescript-react-apollo to completely skip the document nodes could work as a solution (perhaps `skip`?)

https://graphql-code-generator.com/docs/plugins/typescript-react-apollo

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.