-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Before describing the bug, let me just drop a big "thank you" for this code generator. Saves a lot of time and headache when managing our React + Apollo app 🙂
Describe the bug
We currently use @graphql-codegen/[email protected] to generate graphql types and helper hooks for the Apollo Client serving our application. So far everything is working fine, however, when trying to update to version 2.2.1, the generated types start to contain several [object Object] instances.
More precisely, this happens within generated Pick<...> types. For example, suppose I have the following type definition:
type MyType {
myFirstField: String;
mySecondField: String;
}
extend type Query {
myObject: MyType
}
query getMyTypeFirstField {
myObject {
myFirstField
}
}Then the result of running the generator outputs a broken type definition:
export type MyTypeFields = Maybe<{ __typename: 'MyType' } & Pick<MyType, '[object Object]'>>The expected output would be:
export type MyTypeFields = Maybe<{ __typename: 'MyType' } & Pick<MyType, 'myFirstField'>>My guess is that this is related to #5104, as the definitions for MakeOptional were updated and MakeMaybe was introduced.
My codegen.yml config file:
overwrite: true
hooks:
afterAllFileWrite:
- "yarn prettier:fix"
schema:
- "src/types/cache/cacheTypeDefs.ts"
documents:
- "src/**/*.ts"
generates:
src/types/generated/cacheTypes.tsx:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-react-apollo"
./graphql.schema.json:
plugins:
- "introspection"