Module apollo_compiler::ast

source ·
Expand description

Abstract Syntax Tree for GraphQL documents. Lower-level than Schema or ExecutableDocument.

This AST aims to faithfully represent documents that conform to the GraphQL syntactic grammar, except for their ignored tokens. These documents may or may not be valid.

Parsing an input that does not conform to the grammar results in parse errors together with a partial AST.

§Parsing

Start with Document::parse, or Parser to change the parser configuration.

§Structural sharing and mutation

Nodes inside documents are wrapped in Node, a reference-counted smart pointer. This allows sharing nodes between documents without cloning entire subtrees. To modify a node, the make_mut method provides copy-on-write semantics.

§Serialization

Document and its node types implement Display and ToString by serializing to GraphQL syntax with a default configuration. serialize methods return a builder that has chaining methods for setting serialization configuration, and also implements Display and ToString.

Structs§

Enums§

Type Aliases§

  • Refers to the name of a GraphQL type defined elsewhere