Class: GraphQL::Stitching::SkipInclude

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

Class Method Summary collapse

Class Method Details

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

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

Yields:

  • (document)


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

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