dotansimha / dotansimha/graphql-code-generator
Never type incorrectly generated for interfaces
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Issue:** Generating type definitions for a query which returns an interface outputs that interface type as `never`
**Steps to reproduce:**
`schema.graphql`:
```
schema {
query: Query
}
type Query {
user(id: ID!): User
}
interface User {
id: ID!
name: String!
}
```
`operations.graphql`
```
query findUser($userId: ID!) {
user(id: $userId) {
id
name
}
}
```
`codegen.yml`
```
generates:
types-and-hooks.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
```
Results in (abbreviated to highlight the issue):
```
...
export type User = {
id: Scalars['ID'];
name: Scalars['String'];
};
export type FindUserQuery = { __typename?: 'Query', user?: never | null };
...
```
You can reproduce this at https://www.graphql-code-generator.com/ by inputting the same values for the various files into the appropriate input fields within that UI.
**Expected result:** The `export type FindUserQuery` should specify the optional `user?: User | null` instead of `user?: never | null`
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.