class GraphQL::Language::Nodes::Document
This is the AST root for normal queries
Examples
Example: Deriving a document by parsing a string
document = GraphQL.parse(query_string)
Example: Creating a string from a document
document.to_query_string # { ... }
Example: Creating a custom string from a document
class VariableScrubber < GraphQL::Language::Printer def print_argument(arg) print_string("#{arg.name}: <HIDDEN>") end end document.to_query_string(printer: VariableScrubber.new)
Attributes
children
[R]
Array[AbstractNode]
Returns
-
Array<OperationDefinition, FragmentDefinition, AbstractNode>— top-levelGraphQLunits: operations or fragments
definitions
[R]
Array[AbstractNode]
Returns
-
Array<OperationDefinition, FragmentDefinition, AbstractNode>— top-levelGraphQLunits: operations or fragments
Public Class Methods
# File lib/graphql/language/nodes.rb, line 1167 def self.from_a(filename, line, col, definitions, comment: nil) self.new(filename: filename, line: line, col: col, definitions: definitions) end
(?definitions: Array[AbstractNode], ?line: Integer?, ?col: Integer?, ?pos: Integer?, ?filename: String?, ?source: untyped) → void
Source
# File lib/graphql/language/nodes.rb, line 1158 def initialize(definitions: NO_CHILDREN, line: nil, col: nil, pos: nil, filename: nil, source: nil) @line = line @col = col @pos = pos @filename = filename @source = source @definitions = definitions.freeze end
Public Instance Methods
Source
# File lib/graphql/language/nodes.rb, line 1171 def marshal_dump [ line, col, # use methods here to force them to be calculated @filename, @definitions, ] end
Source
# File lib/graphql/language/nodes.rb, line 1179 def marshal_load(values) @line, @col, @filename, @definitions = values end
Source
# File lib/graphql/language/nodes.rb, line 1187 def slice_definition(name) GraphQL::Language::DefinitionSlice.slice(self, name) end
Source
# File lib/graphql/language/nodes.rb, line 1145 def visit_method :on_document end