Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement oneOf for input types #2421

Closed
patrick91 opened this issue Dec 26, 2022 · 4 comments · Fixed by #3429
Closed

Implement oneOf for input types #2421

patrick91 opened this issue Dec 26, 2022 · 4 comments · Fixed by #3429
Assignees

Comments

@patrick91
Copy link
Member

patrick91 commented Dec 26, 2022

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: #2420 (reply in thread)

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.
Fund with Polar
@nrbnlulu
Copy link
Member

nrbnlulu commented Feb 13, 2023

Would that be

@strawberry.mutations.oneOf()
def foo(arg1: Optional[str], arg2: Optional[int]):
    ...

or use enums like async-graphql?

@estyxx estyxx self-assigned this Feb 18, 2023
@Aponace
Copy link

Aponace commented Jul 3, 2023

Any progress on that? It seems the PR is open and ready but no one approves it :(

@patrick91
Copy link
Member Author

@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 😊

@bradleyoesch
Copy link
Contributor

@patrick91 I'm interested in implementing this!

It seems like we could take #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.

@patrick91 patrick91 mentioned this issue Mar 31, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants