Resolver methods on objects not generated or missing arguments #1810
Unanswered
henrywoody
asked this question in
Q&A
Replies: 1 comment
-
Upon further thought, it now seems that even if the conditions for |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What happened?
I've noticed some strange behavior with the generation of resolver methods that belong to specific objects (rather than to the root query).
In some cases the resolver method is not generated at all (in cases where I believe the method should be generated), in other cases the resolver method is generated but does not include the arguments specified in the schema.
In most cases the resolver method is correctly either generated or not generated, but the cases mentioned above differ from my expectation of behavior.
Here is an outline of setup and resulting behavior that I've worked out:
MethodName
) Setup — ResultDoesNotMakeResolver1
) Matching method (by name) on object type exists but takes no arguments and has correct return values — No resolver generated (incorrect)DoesNotMakeResolver2
) Matching method on object type exists but takes an argument defined by the resolver method (but not those defined by the schema) and has correct return values — No resolver generated (incorrect)DoesNotMakeResolver3
,DoesNotMakeResolver4
) Matching method on object type exists and takes an argument (but not all) defined by the schema method (but not those defined by the resolver, i.e.ctx
) and has correct return values — No resolver generated (incorrect)CorrectlyDoesNotMakeResolver
) Matching method on object type exists and takes all arguments defined by the resolver and schema and has correct return values — No resolver generated (correct)MakesResolverButMissingArguments
) Matching method on object type exists but lacks arguments defined by the schema and has differing return type from resolver — Resolver generated (correct) but missing arguments defined in the schema (incorrect)MakesResolverWithAllArguments
) Matching method on object type exists and has all arguments defined by the resolver and schema but has differing return type from resolver — Resolver generated with correct arguments (correct)MakesResolver1
) Matching method on object does not exist — Resolver generated (correct)MakesResolver2
) Matching method on object exists and takes arguments whose types do not match those of the resolver/schema — Resolver generated (correct)MakesResolver3
) Matching method on object exists and takes all correct arguments but argument names do not match (types do) — Resolver generated (not sure but I lean to incorrect)There are likely some other cases but these are the ones that I've found and that matter to my usecase.
What did you expect?
I expect a resolver method to be generated if there is no existing method with all the correct arguments and the correct return values. And I expect no resolver method to be generated if such a method exists. Finally, if a method is generated, I expect its signature to include the arguments specified in the schema.
Minimal graphql.schema and models to reproduce
Schema
Models
Resulting Resolvers
Final Comments/Questions
Much of the unexpected behavior seems like a bug because the missing resolvers have methods that do not match the types/arguments that the resolvers require. Given that, is there a way I can change the configuration so that methods on objects are not bound automatically by default?
Also the reason much of this matters (and why I can't just update the methods defined on my types) is that I'm using
ent
to generate my model definitions.versions
gqlgen version
? 0.13.0go version
? 1.15Beta Was this translation helpful? Give feedback.
All reactions