Class: GraphQL::Stitching::Resolver::KeyField

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/stitching/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.



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

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

Instance Attribute Details

#innerObject (readonly)

inner key selections



91
92
93
# File 'lib/graphql/stitching/resolver/keys.rb', line 91

def inner
  @inner
end

#listObject Also known as: list?

Returns the value of attribute list.



95
96
97
# File 'lib/graphql/stitching/resolver/keys.rb', line 95

def list
  @list
end

#nameObject (readonly)

name of the key, may be a field alias



88
89
90
# File 'lib/graphql/stitching/resolver/keys.rb', line 88

def name
  @name
end

#type_nameObject

optional information about location and typing, used during composition



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

def type_name
  @type_name
end

Instance Method Details

#export_nodeObject



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

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

#to_definitionObject



104
105
106
# File 'lib/graphql/stitching/resolver/keys.rb', line 104

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