Class: GraphQL::Stitching::TypeResolver::FieldNode

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

Constant Summary collapse

GRAPHQL_RUBY_FIELD_ALIAS_KWARG =

GraphQL Ruby changed the argument assigning Field.alias from a generic alias hash key to a structured field_alias kwarg in https://github.com/rmosolgo/graphql-ruby/pull/4718. This adapts to the library implementation present.

!GraphQL::Language::Nodes::Field.new(field_alias: "a").alias.nil?

Class Method Summary collapse

Class Method Details

.build(field_name:, field_alias: nil, selections: GraphQL::Stitching::EMPTY_ARRAY) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/graphql/stitching/type_resolver/keys.rb', line 15

def build(field_name:, field_alias: nil, selections: GraphQL::Stitching::EMPTY_ARRAY)
  if GRAPHQL_RUBY_FIELD_ALIAS_KWARG
    GraphQL::Language::Nodes::Field.new(
      field_alias: field_alias,
      name: field_name,
      selections: selections,
    )
  else
    GraphQL::Language::Nodes::Field.new(
      alias: field_alias,
      name: field_name,
      selections: selections,
    )
  end
end