You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interface AB {
id: String!
}
type AConfig {
key: String!
}
type BConfig {
value: String!
}
type A implements AB {
id: String!
config: AConfig!
}
type B implements AB {
id: String!
config: BConfig!
}
type Query {
ab(id: String!): AB
}
And this operation:
query GetAB($id: String!) {
ab(id: $id) {
id
... on A {
config {
key
}
}
... on B {
config {
value
}
}
}
}
Which packages are impacted by your issue?
@graphql-codegen/typescript-operations
Describe the bug
Description
If I use a template
MaybeValue
like suggested hereAnd I use the default
preResolveTypes: true
then the generated types will be broken for simple queries.Your Example Website or App
https://stackblitz.com/edit/github-55hzb3?file=codegen.ts,document.graphql,schema.graphql,types.ts
Steps to Reproduce the Bug or Issue
Given this schema:
And this operation:
And this codegen-config:
Then the generated type for the query operation defined above will be generated as:
But
ab
here resolves toany
becauseT
is not defined (since it has preResolved the types and removed theMaybe
wrapper.If I instead set
preResolveTypes: false
, it works as expected (but I expect this to work with the default values too).Expected behavior
I expected
ab
not be resolved toany
whenpreResolveTypes: true
is set.Screenshots or Videos
No response
Platform
graphql
version: 16.2.0@graphql-codegen/*
version(s): 4.0.1Codegen Config File
Additional context
No response
The text was updated successfully, but these errors were encountered: