-
Notifications
You must be signed in to change notification settings - Fork 92
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
Turn Java overrides into GraphQL OneOf #2099
Comments
Maybe we could even implement the inverse on the client side. We'd need more thinking on that. |
I think that is a good idea, what would happen if the user set both ? |
The server returns an error explaining that the client should set exactly one. BTW: you really look like an Australian now 😎 |
A, ok , so that is what the OneOf will do ? Can this be done with a directive on the client side ? |
You can already accomplish the same by doing
and it feels like less magic to me |
The Doing it manually by hand is surely less magic, but more work... one could say that for GraphQL, too 😜 |
My question in the oneOf-discussion was answered. Now I understand why the |
There is validation for it built into graphql-java |
Say I have multiple methods in a GraphQL API class with the same name but different parameters:
Currently, one
add
method overwrites the other, so we end up with only a singleadd
mutation. We probably should consider this a bug; it should at least throw a validation error.But we can do even better: we could derive a schema like this:
And we would validate that exactly one parameter is set; and then call the correct method.
But the fact that a client must provide exactly one argument would not be visible in the schema. The
@oneOf
directive being discussed for the GraphQL spec is only valid on Input types (yet).I'm not sure we want to live without this information nor define our own directive like
oneOfParameters
, so we could also go for a regular@oneOf
wrapper type:This would be conforming to the upcoming
@oneOf
spec, but make the queries a bit more verbose:What do you think?
The text was updated successfully, but these errors were encountered: