Class: GraphQL::Query::SerialExecution::ValueResolution::HasPossibleTypeResolution

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

Instance Attribute Summary

Attributes inherited from BaseResolution

#execution_context, #field_type, #irep_node, #parent_type, #target, #value

Instance Method Summary collapse

Methods inherited from BaseResolution

#get_strategy_for_kind, #initialize, #result

Constructor Details

This class inherits a constructor from GraphQL::Query::SerialExecution::ValueResolution::BaseResolution

Instance Method Details

#non_null_resultObject


62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/graphql/query/serial_execution/value_resolution.rb', line 62

def non_null_result
  resolved_type = execution_context.schema.resolve_type(value, execution_context.query.context)
  possible_types = execution_context.schema.possible_types(field_type)

  unless resolved_type.is_a?(GraphQL::ObjectType) && possible_types.include?(resolved_type)
    raise GraphQL::UnresolvedTypeError.new(irep_node.definition_name, execution_context.schema, field_type, parent_type, resolved_type)
  end

  strategy_class = get_strategy_for_kind(resolved_type.kind)
  inner_strategy = strategy_class.new(value, resolved_type, target, parent_type, irep_node, execution_context)
  inner_strategy.result
end