dotansimha / dotansimha/graphql-code-generator

Better Support for `@oneof` Input Directive

Open
#10,524 0 comments 6 reactions 1 assignee Claimed by @eddeee888 View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### 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](https://github.com/hueter/graphql-codegen-input-oneof/tree/main) with a minimal reproduction of the issue I'm facing.

The backend (GraphQL Ruby - [docs](https://graphql-ruby.org/type_definitions/input_objects.html#oneof)) [correctly adds](https://github.com/hueter/graphql-codegen-input-oneof/blob/c8bd4bd0e49b5f0bfd41e72a0d20e7627a55c0a6/server/app/graphql/types/search_filter_input_type.rb#L5-L9) 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](https://github.com/dotansimha/graphql-code-generator/issues/10472) 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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.