Module: GraphQL::Execution::Lookahead::FieldHelpers

Defined in:
lib/graphql/execution/lookahead.rb

Overview

TODO dedup with interpreter

Class Method Summary collapse

Class Method Details

.get_field(schema, owner_type, field_name) ⇒ Object



309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/graphql/execution/lookahead.rb', line 309

def get_field(schema, owner_type, field_name )
  field_defn = owner_type.get_field(field_name)
  field_defn ||= if owner_type == schema.query.[:type_class] && (entry_point_field = schema.introspection_system.entry_point(name: field_name))
    entry_point_field.[:type_class]
  elsif (dynamic_field = schema.introspection_system.dynamic_field(name: field_name))
    dynamic_field.[:type_class]
  else
    raise "Invariant: no field for #{owner_type}.#{field_name}"
  end

  field_defn
end