Class: GraphQL::Stitching::SkipInclude Private

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

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Faster implementation of an AST visitor for prerendering This avoids unnecessary planning steps, and prepares result shaping.

Class Method Summary collapse

Class Method Details

.render(document, variables) {|document| ... } ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Yields:

  • (document)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/graphql/stitching/skip_include.rb', line 11

def render(document, variables)
  changed = false
  definitions = document.definitions.map do |original_definition|
    definition = render_node(original_definition, variables)
    changed ||= definition.object_id != original_definition.object_id
    definition
  end

  return document unless changed

  document = document.merge(definitions: definitions)
  yield(document) if block_given?
  document
end