graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

@oneOf support broken with interfaces

Open levrik opened this issue 3 years ago • 2 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure the Codegen and plugins version under package.json matches 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

  1. 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]
}
  1. My codegen.yml config 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 avatar Jun 14 '22 06:06 levrik

@levrik Do you think you can create a pull request with a failing test case for this?

n1ru4l avatar Jul 04 '22 14:07 n1ru4l

@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.

levrik avatar Jul 04 '22 14:07 levrik

I've suggested a fix in #8586

levrik avatar Nov 08 '22 09:11 levrik