-
Notifications
You must be signed in to change notification settings - Fork 174
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
FieldResolverError with resolver for superclass or interface #497
Comments
I have a working solution here but it probably needs some more work before it can be turned into a PR. |
I am not saying that this is not a bug (or maybe should work), but i think you can work around that by doing this:
Although |
Right, but that kinda defeats the purpose of polymorphism here. If you have a ThingA, ThingB, ThingC, etc. you'll still have to create a resolver for each of those subclasses, just not the implementation. So it's only really half of a solution, since in some cases you don't exactly know what the subclasses are at compile time, making this very fragile. Also yeah |
How so? Regarding the issue: I guess it make make sense to check for resolvers up the ancestor chain starting at the most concrete resolver (since it might override properties). Although i am not sure if this is really worth the effort. Most of the time the concrete classes will not be empty and you would need a resolver for those anyways, and this resolver could then just extend the |
In situations with dynamic linking or as part of a library. |
I see. Although those could probably still just write their own resolvers (extending your base resolver) when extending your base class, right? But i see how this could be more beneficial now. Thanks for explaining your use-case. |
I'm coming a little late on this, but I faced the same issue. Actually, @KammererTob's proposition didn't work for me right out of the box, but I was able to make it work in a pretty similar way if anyone needs it abstract class BaseResolver<T : Base> : GraphQLResolver<T> {
fun isActive(base: T) : Boolean {
return true
}
}
class ThinkResolver : BaseResolver<Thing> That being said, I agree with @florensie that it would be great to be able to provide only the |
Description
Consider the following dataclass hierarchy:
This is a custom resolver for the abstract class
Base
:Root query resolver with datafetcher that returns our concrete class
Thing
:Expected behavior
The following schema should work fine and return true for queries on the
active
field:Actual behavior
Steps to reproduce the bug
The text was updated successfully, but these errors were encountered: