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

Better Support for `@oneof` Input Directive

Open hueter opened this issue 1 month ago • 0 comments

Is your feature request related to a problem? Please describe.

Hello,

I just wanted to flag that the typescript and schema-ast plugins don't seem to fully support the @oneOf directive for input types.

I have an example repository here with a minimal reproduction of the issue I'm facing.

The backend (GraphQL Ruby - docs) correctly adds the @oneof to an input, but the code generated ignores it.

schema-ast plugin output:

https://github.com/hueter/graphql-codegen-input-oneof/blob/c8bd4bd0e49b5f0bfd41e72a0d20e7627a55c0a6/generated/schema.graphql#L15-L20

typescript plugin output:

https://github.com/hueter/graphql-codegen-input-oneof/blob/c8bd4bd0e49b5f0bfd41e72a0d20e7627a55c0a6/generated/types.ts#L31-L36

codegen configs:

https://github.com/hueter/graphql-codegen-input-oneof/blob/c8bd4bd0e49b5f0bfd41e72a0d20e7627a55c0a6/codegen.ts#L3-L19

Describe the solution you'd like

I was hoping that it would output a TypeScript discriminated union as well as include the @oneof directive in the generated schema. I saw this issue which talked about (an imaginary?) config but couldn't see it documented / not sure if it's real.

Describe alternatives you've considered

No response

Any additional important details?

No response

hueter avatar Nov 25 '25 19:11 hueter