Class: GraphQL::Query::SerialExecution::FieldResolution

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query/serial_execution/field_resolution.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast_node, parent_type, target, execution_context) ⇒ FieldResolution

Returns a new instance of FieldResolution.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 7

def initialize(ast_node, parent_type, target, execution_context)
  @ast_node = ast_node
  @parent_type = parent_type
  @target = target
  @execution_context = execution_context
  @field =  execution_context.get_field(parent_type, ast_node.name)
  if @field.nil?
    raise("No field found on #{parent_type.name} '#{parent_type}' for '#{ast_node.name}'")
  end
  @arguments = GraphQL::Query::LiteralInput.from_arguments(
    ast_node.arguments,
    field.arguments,
    execution_context.query.variables
  )
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



5
6
7
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 5

def arguments
  @arguments
end

#ast_nodeObject (readonly)

Returns the value of attribute ast_node.



5
6
7
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 5

def ast_node
  @ast_node
end

#execution_contextObject (readonly)

Returns the value of attribute execution_context.



5
6
7
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 5

def execution_context
  @execution_context
end

#fieldObject (readonly)

Returns the value of attribute field.



5
6
7
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 5

def field
  @field
end

#parent_typeObject (readonly)

Returns the value of attribute parent_type.



5
6
7
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 5

def parent_type
  @parent_type
end

#targetObject (readonly)

Returns the value of attribute target.



5
6
7
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 5

def target
  @target
end

Instance Method Details

#resultObject



23
24
25
26
27
28
29
30
31
# File 'lib/graphql/query/serial_execution/field_resolution.rb', line 23

def result
  result_name = ast_node.alias || ast_node.name
  raw_value = begin
    get_raw_value
  rescue GraphQL::ExecutionError => err
    err
  end
  { result_name => get_finished_value(raw_value) }
end