dotansimha / dotansimha/graphql-code-generator

Schemas having different query types are not merged properly

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

Description

### Describe the bug

If two schemas merged which have different query type name (like `Query` and `RootQuery`) one of them is lost during the merging meaning certain queries (which are based on the 'lost' schema) will indicate schema errors.

### Your Example Website or App

https://codesandbox.io/s/twilight-dream-1snwfw

### Steps to Reproduce the Bug or Issue

1. Go to https://codesandbox.io/s/twilight-dream-1snwfw.
2. In terminal run `yarn generate`.
3. Notice the generation fails with validation error. This is because during merging the `Query` query type has been lost and the validation of the `user` query is failed.

### Expected behavior

I am by no means a GraphQL expert, but I assume there can only be one query type in the schema, it is `Query` if we don't specify explicitly, but we can also specify it like:
```
schema {
query: Query
}
```
And even we can use a different name for the type:
```
schema {
query: RootQuery
}
```
But still, there is only one such type per schema, so I think this still could be merged properly.

### Screenshots or Videos

_No response_

### Platform

- OS: tested on MacOS, but this is not OS specific
- NodeJS: 16.15.1.
- `graphql` version: 16.2.0
- `@graphql-codegen/*` version: 2.13.7

### Codegen Config File

_No response_

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