Describe the bug
It seems the __typename field cannot be requested in a query when using the near-operation-file preset.
To Reproduce
Steps to reproduce the behavior:
The bug can be reproduced in this sandbox: https://codesandbox.io/s/graphql-codegen-issue-template-95ugn
type Query {
user(id: ID!): User!
}
type User {
id: ID!
username: String!
email: String!
}
query user {
user(id: 1) {
__typename
id
username
}
}
codegen.yml config file:schema: schema.graphql
documents: document.graphql
generates:
types.ts:
preset: near-operation-file
presetConfig:
baseTypesPath: types.ts
plugins:
- typescript
- typescript-operations
Expected behavior
I would expect the types to be generated as normal with a non-null __typename field when it is asked for.
Environment:
@graphql-codegen/...: Additional context
Removing the preset allows this to work as expected.
fwiw this also happens if you use fragments with __typename, which is how I came across the issue: https://codesandbox.io/s/graphql-codegen-issue-template-6vv5g
@seansfkelley I think I managed to fix this issue in: https://github.com/dotansimha/graphql-code-generator/commit/d70efb5045e31ee0b331170314e0f4204be4c911
Can you please try the alpha version? 1.8.3-alpha-691249fe.22
@dotansimha I can confirm that 1.8.3-alpha-691249fe.22 fixes the issue. Thank you very much!
Fixed in 1.8.3