Method: GraphQL::Language::Visitor#visit_selections

Defined in:
lib/graphql/language/visitor.rb

#visit_selections(new_node) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/graphql/language/visitor.rb', line 101

def visit_selections(new_node)
  new_node.selections.each do |selection|
    new_child_and_node = case selection
    when GraphQL::Language::Nodes::Field
      on_field_with_modifications(selection, new_node)
    when GraphQL::Language::Nodes::InlineFragment
      on_inline_fragment_with_modifications(selection, new_node)
    when GraphQL::Language::Nodes::FragmentSpread
      on_fragment_spread_with_modifications(selection, new_node)
    else
      raise ArgumentError, "Invariant: unexpected field selection #{selection.class} (#{selection.inspect})"
    end
    # Reassign `node` in case the child hook makes a modification
    if new_child_and_node.is_a?(Array)
      new_node = new_child_and_node[1]
    end
  end
  new_node
end