Method: GraphQL::Schema::Resolver#resolve_with_support
- Defined in:
- lib/graphql/schema/resolver.rb
#resolve_with_support(**args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method is actually called by the runtime,
it does some preparation and then eventually calls
the user-defined #resolve method.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/graphql/schema/resolver.rb', line 65 def resolve_with_support(**args) # First call the ready? hook which may raise raw_ready_val = if !args.empty? ready?(**args) else ready? end context.query.after_lazy(raw_ready_val) do |ready_val| if ready_val.is_a?(Array) is_ready, ready_early_return = ready_val if is_ready != false raise "Unexpected result from #ready? (expected `true`, `false` or `[false, {...}]`): [#{is_ready.inspect}, #{ready_early_return.inspect}]" else ready_early_return end elsif ready_val # Then call each prepare hook, which may return a different value # for that argument, or may return a lazy object load_arguments_val = load_arguments(args) context.query.after_lazy(load_arguments_val) do |loaded_args| @prepared_arguments = loaded_args Schema::Validator.validate!(self.class.validators, object, context, loaded_args, as: @field) # Then call `authorized?`, which may raise or may return a lazy object = if !loaded_args.empty? (**loaded_args) else end context.query.after_lazy() do || # If the `authorized?` returned two values, `false, early_return`, # then use the early return value instead of continuing if .is_a?(Array) , early_return = if == false early_return else raise "Unexpected result from #authorized? (expected `true`, `false` or `[false, {...}]`): [#{authorized_result.inspect}, #{early_return.inspect}]" end elsif # Finally, all the hooks have passed, so resolve it call_resolve(loaded_args) else raise GraphQL::.new(context: context, object: object, type: field.owner, field: field) end end end end end end |