MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
https://typegraphql.com
MIT License
8.03k stars 676 forks source link

@oneOf directive support #1542

Open mengledowl opened 12 months ago

mengledowl commented 12 months ago

The GraphQL working group recently upgraded the @oneOf directive RFC (https://github.com/graphql/graphql-spec/pull/825) to RFC 2, which states:

GraphQL libraries should implement drafts to provide valuable feedback, though are encouraged not to enable the draft feature without explicit opt-in when possible.

This is one of the most anticipated (IMO) new additions to the spec, and the work has already been done for graphql-js (though unreleased as of yet).

I would like to propose that this feature be exposed in TypeGraphQL for those of us who want to have early access to it. I'm not sure what would be involved in that effort (if any), but wanted to get the conversation started.

MichalLytek commented 11 months ago

@Directive("@oneof")? 🤔

pmooney-socraticworks commented 3 months ago

@MichalLytek Can you expand on your response or provide an example please? I'm running into this same issue, and the path forward on@oneOf is unclear to me.

MichalLytek commented 2 months ago

@Directive("@oneof") is used to put schema directive on your input field, as the new graphql spec says.

Then you need a graphql runtime that supports this directive (new graphql-js does it) so it will apply runtime logic to your input type.