Crate async_graphql[][src]

Expand description

A GraphQL server library implemented in Rust

Crates.io version Download docs.rs docs Unsafe Rust forbidden

Documentation

Features

  • Fully supports async/await
  • Type safety
  • Rustfmt friendly (Procedural Macro)
  • Custom scalars
  • Minimal overhead
  • Easy integration (poem, actix_web, tide, warp, rocket …)
  • File upload (Multipart request)
  • Subscriptions (WebSocket transport)
  • Custom extensions
  • Apollo Tracing extension
  • Limit query complexity/depth
  • Error Extensions
  • Apollo Federation
  • Batch Queries
  • Apollo Persisted Queries

Crate features

This crate offers the following features, all of which are not activated by default:

Integrations

License

Licensed under either of

References

Examples

All examples are in the sub-repository, located in the examples directory.

Run an example:

git submodule update # update the examples repo
cd examples && cargo run --bin [name]

Benchmarks

Ensure that there is no CPU-heavy process in background!

cd benchmark
cargo bench

Now a HTML report is available at benchmark/target/criterion/report.

Re-exports

pub use async_graphql_parser as parser;
pub use resolver_utils::ContainerType;
pub use resolver_utils::EnumType;
pub use resolver_utils::ScalarType;
pub use context::*;
pub use parser::Pos;
pub use parser::Positioned;
pub use types::*;

Modules

Query context.

dataloaderdataloader

Batch loading support, used to solve N+1 problem.

Extensions for schema

Field guards

A helper module that supports HTTP

Utilities for implementing OutputType::resolve.

Useful GraphQL types.

Input value validators

Macros

Define a scalar

Construct a ConstValue.

Structs

Cache control values

This type represents errors that can occur when deserializing.

An error with a message and optional extensions.

Extensions to the error.

An error parsing an input value.

A selection performed by a query.

A GraphQL name.

Represents a JSON number, whether integer or floating point.

GraphQL request.

Query response

GraphQL schema.

Schema builder

This type represents errors that can occur when serializing.

An error in a GraphQL server.

Validation results.

Variables of a query.

Enums

Batch support for GraphQL requests, which is either a single query, or an array of queries

Response for batchable queries

An error parsing the request.

A segment of path to a resolver.

Validation mode

A resolved GraphQL value, for example 1 or "Hello World!".

Traits

An error which can be extended into a Error.

A GraphQL input object.

Represents a GraphQL input value.

A GraphQL interface.

A GraphQL object.

Represents a GraphQL output value.

Extend a Result’s error value with ErrorExtensions.

Represents a GraphQL type.

A GraphQL interface.

Functions

Interpret a ConstValue as an instance of type T.

Convert a T into ConstValue which is an enum that can represent any valid GraphQL data.

Type Definitions

An alias of async_graphql::Error. Present for backward compatibility reasons.

An alias of async_graphql::Result. Present for backward compatibility reasons.

An error parsing a value of type T.

An alias for Result<T, Error>.

Alias for Result<T, ServerError>.

Attribute Macros

Define a complex GraphQL object for SimpleObject’s complex field resolver.

Define a GraphQL object with methods

Define a Scalar

Define a GraphQL subscription

Derive Macros

Attach a description to Object, Scalar or Subscription.

Define a GraphQL enum

Define a GraphQL input object

Define a GraphQL interface

Define a merged object with multiple object types.

Define a merged subscription with multiple subscription types.

Define a NewType Scalar

Define a GraphQL object with fields

Define a GraphQL union