-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adding field with resolver on a Type causes "Can't determine the return type " error on a different Type #3974
Comments
I've worked around this for now by adding a new |
Hey, sorry for the trouble! Thanks for the detailed report.
Yep ... and I think this spot is particularly tough, since it's the I think you could get around this by using a string for the type name: module Resolvers
class TodosResolver < GraphQL::Schema::Resolver
- type [Types::TodoType], null: false
+ type "[Types::TodoType]", null: false I think that would defer the reference to |
Perfect! Thanks so much. |
@rmosolgo hmm, what if your type looks like this type Types::IssueType.connection_type, null: true Quoting it won't help in this case 🤔 |
Want to give that a try? |
Thanks, that did the trick! |
This trick didn't work for me. When doing this, I end up getting type errors in my paginated data query from my front end. |
Hey @yannickgloster, I'd be happy to help you debug this. If you're interested, please open a new issue with all the relevant details (resolver definition, example query, full error message, etc). |
Describe the bug
We are using a resolver
Resolvers::TodoResolver
on a fieldtodos
that is already present on two types –QueryType
andWorkType
. The resolver declares the type withtype [Types::TodoType], null: false
(see code below).When we add a
todos
fieldUserType
with the same resolver, we receive an error with the message: "Can't determine the return type for Work.todos (it hasresolver: Resolvers::TodosResolver
, consider configuration atype ...
for that class)"Removing the
todos
field fromUserType
, or replacing it with a definition that does not include the resolver, does not raise the error.Versions
graphql
version: 1.13.10rails
(or other framework): Rails 6.1.4.4other applicable versions (
graphql-batch
, etc)graphql-batch (0.5.0)
promise.rb (0.7.4)
GraphQL schema
Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?
Steps to reproduce
Steps to reproduce the behavior
Expected behavior
No error should be raised. The
todos
field should be available onQueryType
,WorkType
, andUserType
Actual behavior
Error was raised
Place full backtrace here (if a Ruby exception is involved):
Click to view exception backtrace
Additional context
I notice a slight change in the error message in v2, referencing cyclic conditions, but can't upgrade to 2 yet because of the graphql-batch restriction.
The text was updated successfully, but these errors were encountered: