pub struct Document<'a> {
pub definitions: Vec<'a, Definition<'a>>,
pub size_hint: usize,
}
Expand description
AST Root Node for a GraphQL query language document. This contains one or more definitions of fragments or operations.
Fields§
§definitions: Vec<'a, Definition<'a>>
§size_hint: usize
A hint on how large the source text was from which this Document was parsed.
This gives an initial indication of the starting capacity of a String
that will hold the stringified
document.
Implementations§
Source§impl<'a, 'b> Document<'a>
impl<'a, 'b> Document<'a>
Sourcepub fn fragments(
&'a self,
ctx: &'a ASTContext,
) -> HashMap<&str, &'a FragmentDefinition<'a>, DefaultHashBuilder, &'a Bump>
pub fn fragments( &'a self, ctx: &'a ASTContext, ) -> HashMap<&str, &'a FragmentDefinition<'a>, DefaultHashBuilder, &'a Bump>
Returns a Map
keyed by all fragment names mapped to their fragment definitions.
This is useful for manually traversing the document and resolving FragmentSpread
nodes to
their definitions.
Trait Implementations§
Source§impl<'a> FoldDocument<'a> for Document<'a>
impl<'a> FoldDocument<'a> for Document<'a>
Source§fn fold_operation<'b, F: Folder<'a>>(
&'a self,
ctx: &'a ASTContext,
operation_name: Option<&'a str>,
folder: &'b mut F,
) -> Result<&'a Self>
fn fold_operation<'b, F: Folder<'a>>( &'a self, ctx: &'a ASTContext, operation_name: Option<&'a str>, folder: &'b mut F, ) -> Result<&'a Self>
Folds a GraphQL document by a given operation instead. Instead of transforming the given
document in its entirety fold_operation
will start at the defined operation instead,
transforming fragments only as they’re referred to via FragmentSpread
nodes. This will
create a new document that only refers to and contains the specified operation
.