Describe the bug
When having preResolveTypes enabled Fragment used within a GraphQL ... on SomeType is not generated.
GraphQL
query SomeQuery {
object {
id
... on SomeType {
name
...FragmentName
}
}
}
TypeScript (_no fragment in the type_)
type SomeQuery {
object: Maybe<(
| { id: string }
| { id: string; name: string }
)>;
}
Without the preResolveTypes types is correctly generated
TypeScript
type SomeQuery {
object: Maybe<(
| Pick<GlobalType, 'id'>
| Pick<AnotherType, 'id' | 'name'> & FragmentName
)>;
}
_Please not I wrote all the queries and generated types by hand_
To Reproduce
Steps to reproduce the behavior:
preResolveTypescodegen.yml config file:overwrite: true
schema: "http://localhost:4000/graphql"
documents: "./projects/**/*.graphql.ts"
generates:
./generated/graphql.d.ts:
plugins:
- "typescript"
- "typescript-operations"
config:
avoidOptionals: true
dedupeOperationSuffix: true
immutableTypes: true
# preResolveTypes: true
nonOptionalTypename: true
declarationKind: "interface"
./generated/schema.json:
plugins:
- "introspection"
./generated/introspection-result.ts:
plugins:
- fragment-matcher
Expected behavior
Environment:
@klemenoslaj Can you please try the latest alpha version? 1.7.1-alpha-1e9152fb.90, it has major fixes for the selection set transformation, and I think I fixed this issue as well.
@dotansimha, just checked it, and yes, it's indeed fixed in this alpha version.
Thanks for the great work :+1:
Fixed in 1.8.0 馃殌