-
Notifications
You must be signed in to change notification settings - Fork 95
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
Cant use interface as input #1013
Comments
Thanks @robp94 . I'll have a look a.s.a.p |
@robp94 - I did not forget about this... just been busy, I'll get to it soon. |
No problem, take your time. |
It seems the same issue arises when you try to use a Java 14 record as input. |
For records, we'll need a way to locate the suitable constructor with all fields as arguments, and build an instance using that (rather than use a no-arg constructor and then set each field one by one). I'm trying to do this for the client side now (when typesafe client consumes something that is a record, eg. it is output from the server side), - that actually falls rather under #971. Then if I am successful, I can try the same on server side as input. |
@jmartisk - your records fix would not have solved this, right ? Or would it ? |
No.
I'm not sure if it's worth the hassle - if usage of interfaces is really so important that we can't simply restrict to "concrete classes only". |
We can maybe find an implementation in the code ? And if it exist, use that, else throw an error ? |
What if there are multiple suitable implementations, we won't know which one to pick. Throw an error too? If we require only one implementation of the interface to exist in the code, then that's somewhat against the intended usage of interfaces in Java. And people will get surprised that the application doesn't work just because they have two implementations of an interface. |
I would like to use interfaces like this:
https://graphql.org/learn/schema/#interfaces they would be not dynamic, and all types would be known at build type. |
@jmartisk or pick the first one we find ? |
So if you have an operation like Does the GraphQL spec allow interfaces as inputs at all? How should that look in the schema definition?
while interfaces should be prepended with "interface", it is legal at all to do |
Well, Input (and output) should be plain java object (or interfaces in this case) and should not contain logic. So it should not matter if you create Human or Droid, as your code only care about the interface. Right ? But agree, maybe we should check the spec... |
Hm seems like it actually is not supported https://spec.graphql.org/June2018/#sec-Interfaces Would be good if they would write it on their site and not only in the spec. |
Yeah agreed.. |
When I use an interface as an input, I get an exception:
code-with-quarkus-graphql.zip
#939
The text was updated successfully, but these errors were encountered: