strawberry
strawberry copied to clipboard
Implement oneOf for input types
Might be worth implementing this upcoming feature, unions are not allowed in input types and this is a good alternative to that, also should be easy to implement in code 😊
https://stepzen.com/blog/coming-soon-to-graphql-the-oneof-input-object
It's also been implemented in other libraries, for example async GraphQL (a rust library)
From: https://github.com/strawberry-graphql/strawberry/discussions/2420#discussioncomment-4499708
The specs: https://github.com/graphql/graphql-spec/pull/825/files
Upvote & Fund
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Would that be
@strawberry.mutations.oneOf()
def foo(arg1: Optional[str], arg2: Optional[int]):
...
or use enums like async-graphql?
Any progress on that? It seems the PR is open and ready but no one approves it :(
@Aponace while the PR adds the directive, it doesn't add runtime support for it, we'd need to implement that to make it work 😊
@patrick91 I'm interested in implementing this!
It seems like we could take https://github.com/strawberry-graphql/strawberry/pull/2560 to add @oneOf
as a schema directive, and maybe we could add a ValidationRule
that is added to all schemas? Since this directive would apply on execution, feels more appropriate for a "native" extension or something similar to operation directives.
Seems like the logic is straightforward, just not 100% sure on where the implementation should live.