dotansimha / dotansimha/graphql-code-generator

Argument Type Name Clash

Open
#5,168 5 comments 1 reaction 0 assignees View on GitHub
core plugins stage/1-reproduction
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

**Describe the bug**
Field argument type names clash with certain naming of fields even though the GraphQL schema is valid.

For example:
`Collection.itemTags` and `CollectionItem.tags` both generate types for arguments with the same name `CollectionItemTagsArgs`.

**To Reproduce**
Steps to reproduce the behavior:

Sandbox with minimal reproduction:
https://codesandbox.io/s/fervent-faraday-1r00d?file=/schema.graphql

1. My GraphQL schema:

```graphql
type Query {
collection(id: ID!): Collection!
}

type Collection {
itemTags(aggregate: Boolean): [String]
}

type CollectionItem {
tags(set: String): [String]
}
```

2. My GraphQL operations:

```graphql
query collection {
collection(id: 1) {
itemTags
}
}
```

3. My `codegen.yml` config file:

```yml
schema: schema.graphql
documents: document.graphql
generates:
types.ts:
plugins:
- typescript
- typescript-operations
```

**Expected behavior**
I expected unique type names to be generated for distinct GraphQL types and field arguments.

**Environment:**

- OS:
- `@graphql-codegen/...`: 1.19.4
- NodeJS: v14.15.1

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.