graphql-code-generator
graphql-code-generator copied to clipboard
Support @oneOf in operations plugin
Is your feature request related to a problem? Please describe.
Since @oneOf is already usable via https://www.npmjs.com/package/@envelop/extended-validation it would be great if graphql-codegen could also generate the correct types for (input) object types
Describe the solution you'd like
type Fish {
id: ID!
}
type Tiger {
id: ID!
}
type Dog {
id: ID!
}
type Animal @oneOf {
fish: Fish
tiger: Tiger
dog: Dog
}
type Query {
animal: Animal!
}
query AnimalQuery {
animal {
fish {
__typename
}
tiger {
__typename
}
dog {
__typename
}
}
}
type AnimalQuery = {
animal:
| ({ fish: { __typename: "Fish" } })
| ({ tiger: { __typename: "Tiger" } })
| ({ dog: { __typename: "Dog" } });
};