Skip to content

@oneOf support broken with interfaces #7938

@levrik

Description

@levrik

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions