Skip to content

A graphql depth limit validation in rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

engylemure/graphql_depth_limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql_depth_limit

Crate

A graphql depth limit validation in Rust inspired by graphql_depth_limit

Add this to your Cargo.toml:

[dependencies]
graphql_depth_limit = "0.1.1"

and this to your crate root (if you're using Rust 2015):

extern crate graphql_depth_limit;

Here's a simple example for verification of a graphql query:

use graphql_depth_limit::QueryDepthAnalyzer;

fn main() {
    let query = r#"
                query {
                  a {
                    b {
                      c
                    }
                  }
                }
            "#;
    let depth = match QueryDepthAnalyzer::new(query, vec![], |_a, _b| true) {
        Ok(validator) => validator.verify(5),
        Err(val) => Err(DepthLimitError::Parse(val))
    };
    asssert_eq!(depth.ok()?, 3);
}

About

A graphql depth limit validation in rust

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages