graphql-code-generator
graphql-code-generator copied to clipboard
@oneOf support broken with interfaces
Issue workflow progress
Progress of the issue based on the Contributor Workflow
- [x] 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox
Make sure to fork this template and run
yarn generatein the terminal.Please make sure the Codegen and plugins version under
package.jsonmatches yours.
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
Describe the bug
To Reproduce Steps to reproduce the behavior:
Here's a sandbox showing the broken output:
https://codesandbox.io/s/kind-proskuriakova-h2i4te?file=/types.ts
- My GraphQL schema:
directive @oneOf on INPUT_OBJECT
input IntFilterInput @oneOf {
eq: Int
ne: Int
gt: Int
gte: Int
lt: Int
lte: Int
in: [Int]
}
- My
codegen.ymlconfig file:
schema: schema.graphql
generates:
types.ts:
config:
declarationKind: interface
plugins:
- typescript
Expected behavior
To don't generate invalid TypeScript code.
More specifically either override the interface setting and use type or fall back to no special @oneOf handling.
Environment:
@graphql-codegen/typescript: 2.4.2
@levrik Do you think you can create a pull request with a failing test case for this?
@n1ru4l Since I'm quite busy with other things right now, I hope the linked CodeSandbox above is enough for now. I'll see what I can do if I have a free minute.
I've suggested a fix in #8586