Describe the bug
In 1.5.0, a query that includes a fragment generates a fragment type based on the selections of the fragment.
In 1.6.0, that same query generates only { "__typename": MyType }, regardless of what is in the selection.
To Reproduce
Generate from schema with schema
fragment PriceFragment on Price {
id
item {
... on Product {
...ProductFragment
}
}
...where ProductFragment is included and contains product selections (e.g. id and name).
My GraphQL schema:
Unable to full schema.
My GraphQL operations:
This is not tied to a specfic operation, but the fragment types used in them.
My codegen.yml config file:
overwrite: true
schema: schema.graphql
documents:
[
src/graphql/queries/**/*.graphql,
src/graphql/fragments/**/*.graphql,
src/graphql/mutations/**/*.graphql,
src/graphql/subscriptions/**/*.graphql,
]
generates:
src/components/graphql.tsx:
# hooks:
# afterOneFileWrite:
# - prettier --write
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
- fragment-matcher
config:
namingConvention: keep
withHOC: false
withHooks: true
withComponent: true
typesPrefix: I
nonOptionalTypename: true
avoidOptionals: false
preResolveTypes: false
dedupeOperationSuffix: true
scalars:
Money: number
MoneyInput: number | string
Decimal: number
DecimalInput: number | string
DateTime: string
Date: string
./graphql.schema.json:
plugins:
- introspection
Expected behavior
export type IPriceFragment = { __typename: "Price" } & Pick<IPrice, "id"> & { item: ({ __typename: "Product" } & IProductFragment) }
Environment:
@graphql-codegen/1.6.1: ** Additional Notes
The schema is generated without "errors", but the generated output is not as expected. Reverting to 1.5.0 from 1.6.0 or 1.6.1 restores the expected state of the fragments.
@n1ru4l is it related to your recent changes?
Might be, @jefflewis: Can you please provide a minimal reproduction? Either a CodeSandbox or a Git Repository is fine. Is hard to guess what's wrong without having the schema.
Edit:
See https://github.com/dotansimha/graphql-code-generator/pull/2409 for reproduction.
Should be fixed by https://github.com/dotansimha/graphql-code-generator/pull/2409
Sorry for the inconveniences!
Fixed in 1.7.0
Most helpful comment
Should be fixed by https://github.com/dotansimha/graphql-code-generator/pull/2409
Sorry for the inconveniences!