Class: GraphQL::Stitching::SelectionHint

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

Constant Summary collapse

HINT_PREFIX =
"_STITCH_"

Class Method Summary collapse

Class Method Details

.key(name) ⇒ Object



15
16
17
# File 'lib/graphql/stitching/selection_hint.rb', line 15

def key(name)
  "#{HINT_PREFIX}#{name}"
end

.key?(name) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'lib/graphql/stitching/selection_hint.rb', line 9

def key?(name)
  return false unless name

  name.start_with?(HINT_PREFIX)
end

.key_node(field_name) ⇒ Object



19
20
21
# File 'lib/graphql/stitching/selection_hint.rb', line 19

def key_node(field_name)
  GraphQL::Language::Nodes::Field.new(alias: key(field_name), name: field_name)
end

.typename_nodeObject



23
24
25
# File 'lib/graphql/stitching/selection_hint.rb', line 23

def typename_node
  @typename_node ||= key_node("__typename")
end