-
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
Fix CoercionError handling with null #4799
Conversation
I'm curious about this change because |
graphql-ruby/spec/graphql/schema/scalar_spec.rb Lines 116 to 145 in c2e666d
graphql-ruby/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb Lines 336 to 349 in c2e666d
Lines 183 to 192 in c2e666d
graphql-ruby/spec/graphql/schema/dynamic_members_spec.rb Lines 138 to 158 in c2e666d
So I thought that by inheriting from If there were cases where CoercionError propagated all the way up the stack (and apparently there were...), they were due to an oversight on my part. Do you have backtraces for them? I'd love to figure out what changed here and, if necessary, we could come up with a plan for compatibility. |
I think this is partly due to a single Here's a backtrace of a
It was being handled here: graphql-ruby/lib/graphql/execution/interpreter/runtime.rb Lines 572 to 574 in 04104f1
Now that it's an |
Oh... That's in a custom scalar, right? I'm trying to see if The mention in the docs only addresses incoming values:
Maybe the best thing here is to replace that usage of If it does, I'll improve the docs to suggest that approach for validating outgoing values. |
Yep custom. We can definitely just raise another error that doesn't inherit from |
One other wrinkle to this... a lot of our scalars implement logic like this: class SomeScalar
def coerce_input(value, context)
return if value.nil?
validate_value(value, context)
value
end
def coerce_result(value, context)
validate_value(value, context)
value
end
private
def validate_value(value, context)
unless value.something
raise GraphModel::CoercionError, "invalid value #{value}"
end
end
end This worked great as is but now we'd have to specify which error gets raised in each case. Again, not a huge deal but just wanted to point out our usage. |
Fixes #4740