-
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 a resolver to a new type causes Can't determine the return type
error
#5049
Comments
I've just been able to get around this error by forcibly specifying the type here module Types
class Bar < Types::BaseObject
graphql_name "Bar"
implements GraphQL::Types::Relay::Node
field :foo, type: Types::FooType.connection_type, resolver: Resolvers::Foos
end
end I'm not certain this is recommended practice though. |
Hey, thanks for this detailed report. I agree that what you're describing should work, one way or another. The workaround you found looks great to me. As you probably noticed, a field prioritizes the directly-given graphql-ruby/lib/graphql/schema/field.rb Line 582 in 5a7e235
That behavior is also tested in the gem here: graphql-ruby/spec/graphql/schema/resolver_spec.rb Lines 1111 to 1125 in 5a7e235
So, I expect that to keep working just fine indefinitely. However, the original code should work, and it's on my list to improve GraphQL-Ruby's lazy-loading of type definitions (as part of #5014), so I'll keep this issue open until this issue is addressed better. |
That's great, if you need help with more reproducibility, I'm happy to help provide more context to help get it work (or to break it haha). I couldn't just copy paste the code directly from work, so I may have made a typo while changing all the names. |
Describe the bug
We've got a resolver which loads a lot of items of type
Foo
. This resolver originally only existed on ourquery_type.rb
and could be directly queried from any part of our app.Foo
has a propertyBaz
andBar
also has the propertyBaz
. I was adding the ability to queryFoo
through the same resolver additionally fromBar
.Foo
has quite a lot of filters that we can apply to it and we've got an exporter where we are taking those list of filters from the user and applying them to an exported version. At this stage is where we get the error. The actual app works fine.Versions
graphql-pro
version: 1.26.5rails
(or other framework): ~> 7.0.8.4GraphQL schema
Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok). Any custom extensions, etc?
Steps to reproduce
Expected behavior
It should not error error when accessing a resolver from two places.
Actual behavior
It errored
Place full backtrace here (if a Ruby exception is involved):
Click to view exception backtrace
Additional context
Similar to #3974. I've attempted the suggestions from that thread by wrapping the connection as a string, but it did not work.
The text was updated successfully, but these errors were encountered: