Trait FoldDocument

Source
pub trait FoldDocument<'a>: FoldNode<'a> {
    // Required method
    fn fold_operation<'b, F: Folder<'a>>(
        &'a self,
        ctx: &'a ASTContext,
        operation: Option<&'a str>,
        folder: &'b mut F,
    ) -> Result<&'a Self>;
}
Expand description

Trait for folding a GraphQL Document AST Node by traversing an operation instead of the entire AST tree. This method alters the traversal of the folder and traverses starting from an operation instead; folding the fragment definitions only as they’re used and refered to using FragmentSpread nodes in the operation.

If a Document should instead be transformed and copied in its entirety then Document::fold is a better choice.

Required Methods§

Source

fn fold_operation<'b, F: Folder<'a>>( &'a self, ctx: &'a ASTContext, operation: 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> FoldDocument<'a> for Document<'a>