#graphql #ast #validation #tool #gql

graphql-tools

Tools for working with GraphQL in Rust, based on graphql-parser Document

27 releases

0.2.5 Feb 15, 2024
0.2.3 Jan 29, 2024
0.2.2 Feb 13, 2023
0.2.1 Dec 5, 2022
0.0.9 Dec 28, 2021

#42 in HTTP server

Download history 499/week @ 2024-01-28 548/week @ 2024-02-04 905/week @ 2024-02-11 758/week @ 2024-02-18 734/week @ 2024-02-25 594/week @ 2024-03-03 898/week @ 2024-03-10 1020/week @ 2024-03-17 1016/week @ 2024-03-24 815/week @ 2024-03-31 1085/week @ 2024-04-07 1123/week @ 2024-04-14 1171/week @ 2024-04-21 861/week @ 2024-04-28 1039/week @ 2024-05-05 1010/week @ 2024-05-12

4,131 downloads per month

MIT/Apache

495KB
13K SLoC

graphql-tools (Rust)

Documentation | Crate | GitHub

Note: this crate is still under development (see roadmap below)

The graphql_tools crate implements tooling around GraphQL for Rust libraries. Most of the tools are based on traits and structs implemented in graphql_parser crate.

The goal of this library is to create a common layer of tools that has similar/improved APIs to graphql-js reference implementation and graphql-tools from the JS/TS ecosystem.

Getting Started

Crates.io

Add graphql-tools as a dependency of your project by adding the following to your Cargo.toml file:

[dependencies]
graphql-tools = "..."

Or, if you are using cargo-edit:

cargo add graphql-tools

Roadmap and progress

  • Better documentation
  • AST Visitor for GraphQL schema (graphql_parser::schema::Document)
  • AST Visitor for GraphQL operations (graphql_parser::operation::Document)
  • AST Visitor with TypeInfo
  • AST tools (ongoing)
  • struct extensions
  • GraphQL Validation engine
  • Validation rules
  • GraphQL operations transformer

If you have an idea / missing feature, feel free to open an issue / start a GitHub discussion!

Validation Rules

This comparison is based on graphql-js refernece implementation.

  • ExecutableDefinitions (not actually needed)
  • UniqueOperationNames
  • LoneAnonymousOperation
  • SingleFieldSubscriptions
  • KnownTypeNames
  • FragmentsOnCompositeTypes
  • VariablesAreInputTypes
  • LeafFieldSelections
  • FieldsOnCorrectType
  • UniqueFragmentNames
  • KnownFragmentNames
  • NoUnusedFragments
  • PossibleFragmentSpreads
  • NoFragmentCycles
  • UniqueVariableNames
  • NoUndefinedVariables
  • NoUnusedVariables
  • KnownDirectives
  • UniqueDirectivesPerLocation
  • KnownArgumentNames
  • UniqueArgumentNames
  • ValuesOfCorrectType
  • ProvidedRequiredArguments
  • VariablesInAllowedPosition
  • OverlappingFieldsCanBeMerged
  • UniqueInputFieldNames (blocked by https://github.com/graphql-rust/graphql-parser/issues/59)

Dependencies

~2.3–3.5MB
~70K SLoC