lib/graphql/schema/argument.rb in graphql-2.1.7 vs lib/graphql/schema/argument.rb in graphql-2.1.8
- old
+ new
@@ -219,11 +219,16 @@
# The problem here is, we _used to_ prepare while building variables.
# But now we don't have the runtime object there.
#
# This will have to be called later, when the runtime object _is_ available.
value
- else
+ elsif obj.respond_to?(@prepare)
obj.public_send(@prepare, value)
+ elsif owner.respond_to?(@prepare)
+ owner.public_send(@prepare, value, context || obj.context)
+ else
+ raise "Invalid prepare for #{@owner.name}.name: #{@prepare.inspect}. "\
+ "Could not find prepare method #{@prepare} on #{obj.class} or #{owner}."
end
elsif @prepare.respond_to?(:call)
@prepare.call(value, context || obj.context)
else
raise "Invalid prepare for #{@owner.name}.name: #{@prepare.inspect}"