dotansimha / dotansimha/graphql-code-generator

Support using an alternative name for 'DocumentNode' in generated code

Open
#9,362 1 comment 1 reaction 0 assignees View on GitHub
kind/enhancement
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Is your feature request related to a problem? Please describe.

We happen to have a type in our GraphQL schema named `DocumentNode`. This presents a problem for us, because the generated code is invalid. It contains a duplicate definitions of this name.

The generated code is as follows:

```
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
```

### Describe the solution you'd like

Ideally, the code generator should detect the problem, and generate a unique name.

Alternatively, provide a config option to override the name of the alias.

### Describe alternatives you've considered

I've tried to patch the generator code (using something like `pnpm patch`). It turns out there are multiple packages involved that needs to be patched:

- @graphql-codegen/typed-document-node
- @graphql-codegen/visitor-plugin-common

I think this solution will work, but it's inconvenient.

### Is your feature request related to a problem? Please describe.

_No response_

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.