Module: ApolloFederation::EntitiesField::ClassMethods

Extended by:
GraphQL::Schema::Member::HasFields
Defined in:
lib/apollo-federation/entities_field.rb

Instance Method Summary collapse

Instance Method Details

#define_entities_field(possible_entities) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/apollo-federation/entities_field.rb', line 15

def define_entities_field(possible_entities)
  # If there are any "entities", define the Entity union and and the Query._entities field
  return if possible_entities.empty?

  entity_type = Class.new(Entity) do
    possible_types(*possible_entities)
  end

  field(:_entities, [entity_type, null: true], null: false) do
    argument :representations, [Any], required: true
  end
end