dotansimha / dotansimha/graphql-code-generator

Graphql query generation error

Open
#9,791 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/cli, @graphql-codegen/introspection

### Describe the bug

On trying to generate the code from the following introspection data we get the following error:

```
chema must contain uniquely named types but contains multiple types named "rolesEnum".
Error: Schema must contain uniquely named types but contains multiple types named "rolesEnum".
at new GraphQLSchema (/Users/frontend-template/node_modules/graphql/type/schema.js:219:15)
```

However it seems like if I paste the same introspection json into a file, the codegen just works. Can someone explain whats going on here and what I can do to fix it ? We did some preliminary inspection and we found that the introspection json is coming out correctly.

See this issue for steps to reproduce: https://github.com/dosco/graphjin/issues/449

### Your Example Website or App

https://github.com/dosco/graphjin/tree/f47065f9856ac1c81aef82dd78c557a53f4b0429/examples/webshop

### Steps to Reproduce the Bug or Issue

1. Download the minimal example shown in the above example
2. Run `cd examples/webshop`
3. Run `docker-compose run api db reset`
4. Run `docker-compose up`
5. Download this [repo](https://github.com/rpham-eog/graphjin-codegen-error) and run `yarn codegen`

### Expected behavior

We should not see the error we are seeing regarding repeated `rolesEnum`. I manually verified my introspection json and there is only 1 definition of `rolesEnum`. It should just generate the output.

### Screenshots or Videos

_No response_

### Platform

- OS: [Linux]
- NodeJS: ^20.0.0
- `graphql` version: ^16.7.1
- `@graphql-codegen/*` version(s): 4.0.1

### Codegen Config File

{
overwrite: true,
schema: "http://localhost:8080/api/v1/graphql",
generates: {
"src/graphql/generated.ts": {
plugins: ["typescript", "typescript-document-nodes"]
},
"src/graphql/graphql.schema.json": {
plugins: ["introspection"]
}
}
};

### Additional context

_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.