Module: GraphQL::Language::DefinitionSlice

Extended by:
DefinitionSlice
Included in:
DefinitionSlice
Defined in:
lib/graphql/language/definition_slice.rb

Defined Under Namespace

Classes: DependencyVisitor

Instance Method Summary collapse

Instance Method Details

#slice(document, name) ⇒ Object


7
8
9
10
11
12
13
14
# File 'lib/graphql/language/definition_slice.rb', line 7

def slice(document, name)
  definitions = {}
  document.definitions.each { |d| definitions[d.name] = d }
  names = Set.new
  DependencyVisitor.find_definition_dependencies(definitions, name, names)
  definitions = document.definitions.select { |d| names.include?(d.name) }
  Nodes::Document.new(definitions: definitions)
end