lib/graphql/schema/field.rb
# Convert a GraphQL arguments instance into a Ruby-style hash.
#
# @param obj [GraphQL::Schema::Object] The object where this field is being resolved
# @param graphql_args [GraphQL::Query::Arguments]
# @param field_ctx [GraphQL::Query::Context::FieldResolutionContext]
# @return [Hash<Symbol => Any>]
Convert a GraphQL arguments instance into a Ruby-style hash.
Convert a GraphQL arguments instance into a Ruby - style hash .
def to_ruby_args(obj, graphql_args, field_ctx)
        if graphql_args.any? || @extras.any?
          ruby_kwargs = graphql_args.to_kwargs
          maybe_lazies = []
          arguments.each do |name, arg_defn|
            ruby_kwargs_key = arg_defn.keyword
            if ruby_kwargs.key?(ruby_kwargs_key)
              loads = arg_defn.loads
              value = ruby_kwargs[ruby_kwargs_key]
              loaded_value = if loads && !arg_defn.from_resolver?
                if arg_defn.type.list?
                  loaded_values = value.map { |val| load_application_object(arg_defn, loads, val, field_ctx.query.context) }
                  field_ctx.schema.after_any_lazies(loaded_values) { |result| result }
                else
                  load_application_object(arg_defn, loads, value, field_ctx.query.context)
                end
              elsif arg_defn.type.list? && value.is_a?(Array)
                field_ctx.schema.after_any_lazies(value, &:itself)
              else
                value
              end
              maybe_lazies << field_ctx.schema.after_lazy(loaded_value) do |loaded_value|
                prepared_value = if arg_defn.prepare
                  arg_defn.prepare_value(obj, loaded_value)
                else
                  loaded_value
                end
                ruby_kwargs[ruby_kwargs_key] = prepared_value
              end
            end
          end
          @extras.each do |extra_arg|
            ruby_kwargs[extra_arg] = fetch_extra(extra_arg, field_ctx)
          end
          field_ctx.schema.after_any_lazies(maybe_lazies) do
            ruby_kwargs
          end
        else
          NO_ARGS
        end
      end
def to_ruby_args ( obj , graphql_args , field_ctx ) if graphql_args . any? || @extras . any? ruby_kwargs = graphql_args . to_kwargs maybe_lazies = [ ] arguments . each do | name , arg_defn | ruby_kwargs_key = arg_defn . keyword if ruby_kwargs . key? ( ruby_kwargs_key ) loads = arg_defn . loads value = ruby_kwargs [ ruby_kwargs_key ] loaded_value = if loads && ! arg_defn . from_resolver? if arg_defn . type . list? loaded_values = value . map { | val | load_application_object ( arg_defn , loads , val , field_ctx . query . context ) } field_ctx . schema . after_any_lazies ( loaded_values ) { | result | result } else load_application_object ( arg_defn , loads , value , field_ctx . query . context ) end elsif arg_defn . type . list? && value . is_a? ( Array ) field_ctx . schema . after_any_lazies ( value , & :itself ) else value end maybe_lazies << field_ctx . schema . after_lazy ( loaded_value ) do | loaded_value | prepared_value = if arg_defn . prepare arg_defn . prepare_value ( obj , loaded_value ) else loaded_value end ruby_kwargs [ ruby_kwargs_key ] = prepared_value end end end @extras . each do | extra_arg | ruby_kwargs [ extra_arg ] = fetch_extra ( extra_arg , field_ctx ) end field_ctx . schema . after_any_lazies ( maybe_lazies ) do ruby_kwargs end else NO_ARGS end end
Convert a GraphQL arguments instance into a Ruby-style hash.
Convert a GraphQL arguments instance into a Ruby - style hash .
# Splat the GraphQL::Arguments to Ruby keyword arguments # Apply any `prepare` methods. Not great code organization, can this go somewhere better?
None
Hash<Symbol => Any>
obj
The object where this field is being resolved
The object where this field is being resolved
graphql_args
field_ctx
None