Module: GraphQL::Language::DefinitionSlice

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

Instance Method Summary collapse

Instance Method Details

#slice(document, name) ⇒ Object


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

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