Class: GraphQL::Stitching::TypeResolver::KeyField

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, root: false, inner: EMPTY_FIELD_SET) ⇒ KeyField

Returns a new instance of KeyField.



97
98
99
100
101
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 97

def initialize(name, root: false, inner: EMPTY_FIELD_SET)
  @name = name
  @inner = inner
  @root = root
end

Instance Attribute Details

#innerObject (readonly)

inner key selections



90
91
92
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 90

def inner
  @inner
end

#listObject Also known as: list?

Returns the value of attribute list.



94
95
96
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 94

def list
  @list
end

#nameObject (readonly)

name of the key, may be a field alias



87
88
89
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 87

def name
  @name
end

#type_nameObject

optional information about location and typing, used during composition



93
94
95
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 93

def type_name
  @type_name
end

Instance Method Details

#export_nodeObject



107
108
109
110
111
112
113
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 107

def export_node
  FieldNode.build(
    field_alias: @root ? "#{EXPORT_PREFIX}#{@name}" : nil,
    field_name: @name,
    selections: @inner.export_nodes,
  )
end

#to_definitionObject



103
104
105
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 103

def to_definition
  @inner.empty? ? @name : "#{@name} { #{@inner.to_definition} }"
end