-
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
Possibly unnecessary Schema level resolve_type proc #1193
Comments
Ah, I think you're right, the top-level function should not be required when all abstract members have local functions! Thanks for the detailed description :) |
I'm having this problem as well. |
FWIW - This appears to be fixed in 1.8-dev (as of commit c618943) if the test case is updated to use the new class based API: module This
extend self
def hello
"Hi, from This!"
end
end
module That
extend self
def hello
"Bonjour from That!"
end
end
class ThisType < GraphQL::Schema::Object
field :hello, String, null: false
end
class ThatType < GraphQL::Schema::Object
field :hello, String, null: false
end
class ThisOrThatType < GraphQL::Schema::Union
possible_types ThisType, ThatType
def self.resolve_type(obj, _ctx)
case obj
when This then ThisType
when That then ThatType
end
end
end
class QueryType < GraphQL::Schema::Object
field :thisOrThat, ThisOrThatType, null: false,
resolve: -> (_, _, _) {
[This, That].sample
}
end
class Schema < GraphQL::Schema
query QueryType
end The problem still reproduces in 1.8-dev when using the DSL though. |
That's a nice side-benefit, thanks for updating us! I'm going to close this because:
Feel free to reopen if you find trouble with either of those! |
Hi! I'm not sure if this is a bug, or just a case where I didn't understand the documentation properly but this is a problem I've been running into any time I use union types, though I think it would also apply for interfaces.
When I add a union type to my schema, it fails to validate until I add a
resolve_type
proc to the schema definition. I would have expected that to be unnecessary as long as I defined aresolve_type
proc on the union type itself, which I did. Here's a quick failing ruby script:From what I can tell, the docs around the union type feature don't say that you have to define a
resolve_type
proc on schema, but that aresolve_type
proc must be defined either on the schema, or on the union type.It seems to me like the schema should validate without the
resolve_type
proc being defined at the schema level, especially since it appears to function fine when you stub it with a no-op proc.Here's a query for testing out the above schema:
The text was updated successfully, but these errors were encountered: