Class: GraphQL::Stitching::TypeResolver::KeyFieldSet

Inherits:
Array
  • Object
show all
Defined in:
lib/graphql/stitching/type_resolver/keys.rb

Direct Known Subclasses

Key

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ KeyFieldSet

Returns a new instance of KeyFieldSet.



34
35
36
37
38
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 34

def initialize(fields)
  super(fields.sort_by(&:name))
  @to_definition = nil
  @export_nodes = nil
end

Instance Method Details

#==(other) ⇒ Object



40
41
42
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 40

def ==(other)
  to_definition == other.to_definition
end

#export_nodesObject



54
55
56
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 54

def export_nodes
  @export_nodes ||= map(&:export_node)
end

#primitive_nameObject



44
45
46
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 44

def primitive_name
  length == 1 ? first.name : nil
end

#to_definitionObject Also known as: to_s



48
49
50
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 48

def to_definition
  @to_definition ||= map(&:to_definition).join(" ").freeze
end