123456789_123456789_123456789_123456789_123456789_

Module: GraphQL::Client::QueryTypename

Relationships & Source Files
Namespace Children
Classes:
Defined in: lib/graphql/client/query_typename.rb

Overview

Internal: Insert __typename field selections into query.

Class Method Summary

Class Method Details

.insert_typename_fields(document, types: {})

See additional method definition at line 60.

[ GitHub ]

  
# File 'lib/graphql/client/query_typename.rb', line 67

def self.insert_typename_fields(document, types: {})
  visitor = InsertTypenameVisitor.new(document, types: types)
  visitor.visit
  visitor.result
end

.node_flatten_selections(selections)

[ GitHub ]

  
# File 'lib/graphql/client/query_typename.rb', line 96

def self.node_flatten_selections(selections)
  selections.flat_map do |selection|
    case selection
    when GraphQL::Language::Nodes::Field
      selection
    when GraphQL::Language::Nodes::InlineFragment
      node_flatten_selections(selection.selections)
    else
      []
    end
  end
end