module ApolloFederation::EntitiesField::ClassMethods

Public Instance Methods

define_entities_field(possible_entities) click to toggle source
# 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