lib/graphql/execution/lookahead.rb
# Get a Ruby-ready value from a client query.
# @param graphql_object [Object] The owner of the field whose argument this is
# @param arg_type [Class, GraphQL::Schema::NonNull, GraphQL::Schema::List]
# @param ast_value [GraphQL::Language::Nodes::VariableIdentifier, String, Integer, Float, Boolean]
# @return [Array(is_present, value)]
Get a Ruby-ready value from a client query.
Get a Ruby - ready value from a client query .
def arg_to_value(query, graphql_object, arg_type, ast_value)
          if ast_value.is_a?(GraphQL::Language::Nodes::VariableIdentifier)
            if query.variables.key?(ast_value.name)
              return true, query.variables[ast_value.name]
            else
              return false, nil
            end
          elsif ast_value.is_a?(GraphQL::Language::Nodes::NullValue)
            return true, nil
          elsif arg_type.is_a?(GraphQL::Schema::NonNull)
            arg_to_value(query, graphql_object, arg_type.of_type, ast_value)
          elsif arg_type.is_a?(GraphQL::Schema::List)
            arg_value = Array(ast_value)
            list = []
            arg_value.map do |inner_v|
              _present, value = arg_to_value(query, graphql_object, arg_type.of_type, inner_v)
              list << value
            end
            return true, list
          elsif arg_type.is_a?(Class) && arg_type < GraphQL::Schema::InputObject
            args = arguments(query, nil, arg_type, ast_value)
            return true, arg_type.new(ruby_kwargs: args, context: query.context, defaults_used: nil)
          else
            flat_value = flatten_ast_value(query, ast_value)
            return true, arg_type.coerce_input(flat_value, query.context)
          end
        end
def arg_to_value ( query , graphql_object , arg_type , ast_value ) if ast_value . is_a? ( GraphQL :: Language :: Nodes :: VariableIdentifier ) if query . variables . key? ( ast_value . name ) return true , query . variables [ ast_value . name ] else return false , nil end elsif ast_value . is_a? ( GraphQL :: Language :: Nodes :: NullValue ) return true , nil elsif arg_type . is_a? ( GraphQL :: Schema :: NonNull ) arg_to_value ( query , graphql_object , arg_type . of_type , ast_value ) elsif arg_type . is_a? ( GraphQL :: Schema :: List ) arg_value = Array ( ast_value ) list = [ ] arg_value . map do | inner_v | _present , value = arg_to_value ( query , graphql_object , arg_type . of_type , inner_v ) list << value end return true , list elsif arg_type . is_a? ( Class ) && arg_type < GraphQL :: Schema :: InputObject args = arguments ( query , nil , arg_type , ast_value ) return true , arg_type . new ( ruby_kwargs : args , context : query . context , defaults_used : nil ) else flat_value = flatten_ast_value ( query , ast_value ) return true , arg_type . coerce_input ( flat_value , query . context ) end end
Get a Ruby-ready value from a client query.
Get a Ruby - ready value from a client query .
# If it's not here, it will get added later # Treat a single value like a list # For these, `prepare` is applied during `#initialize`. # Pass `nil` so it will be skipped in `#arguments`. # What a mess. # We're not tracking defaults_used, but for our purposes # we compare the value to the default value.
None
Array(is_present, value)
query
graphql_object
The owner of the field whose argument this is
The owner of the field whose argument this is
arg_type
ast_value
None