Docs.rs
  • async-graphql-5.0.3
    • async-graphql 5.0.3
    • Docs.rs crate page
    • MIT/Apache-2.0
    • Links
    • Homepage
    • Repository
    • crates.io
    • Source
    • Owners
    • sunli829
    • Dependencies
      • async-graphql-derive ^5.0.3 normal
      • async-graphql-parser ^5.0.3 normal
      • async-graphql-value ^5.0.3 normal
      • async-stream ^0.3.0 normal
      • async-trait ^0.1.48 normal
      • base64 ^0.13.0 normal
      • bigdecimal ^0.3.0 normal
      • blocking ^1.0.2 normal
      • bson ^2.4.0 normal
      • bytes ^1.0.1 normal
      • chrono ^0.4.19 normal
      • chrono-tz ^0.6.1 normal
      • fast_chemail ^0.9.6 normal
      • fnv ^1.0.7 normal
      • futures-channel ^0.3.13 normal
      • futures-timer ^3.0.2 normal
      • futures-util ^0.3.0 normal
      • hashbrown ^0.12.0 normal
      • http ^0.2.3 normal
      • indexmap ^1.6.2 normal
      • iso8601-duration ^0.1.0 normal
      • log ^0.4.16 normal
      • lru ^0.7.1 normal
      • mime ^0.3.15 normal
      • multer ^2.0.0 normal
      • num-traits ^0.2.14 normal
      • once_cell ^1.7.2 normal
      • opentelemetry ^0.18.0 normal
      • pin-project-lite ^0.2.6 normal
      • regex ^1.5.5 normal
      • rust_decimal ^1.14.3 normal
      • secrecy ^0.8.0 normal
      • serde ^1.0.125 normal
      • serde_cbor ^0.11.1 normal
      • serde_json ^1.0.64 normal
      • serde_urlencoded ^0.7.0 normal
      • sha2 ^0.10.2 normal
      • smol_str ^0.1.21 normal
      • static_assertions ^1.1.0 normal
      • tempfile ^3.2.0 normal
      • thiserror ^1.0.24 normal
      • time ^0.3.5 normal
      • tokio ^1.17.0 normal
      • tracing-futures ^0.2.5 normal
      • tracing ^0.1.35 normal
      • url ^2.2.1 normal
      • uuid ^1.0.0 normal
      • uuid ^0.8 normal
      • zxcvbn ^2.1.2 normal
      • futures-channel ^0.3.13 dev
      • tokio ^1.4.0 dev
    • Versions
    • 100% of the crate is documented
  • Go to latest version
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation
logo

Crate async_graphql

logo

Crate async_graphql

  • Version 5.0.3
  • All Items
  • Re-exports
  • Modules
  • Macros
  • Structs
  • Enums
  • Traits
  • Functions
  • Type Definitions
  • Attribute Macros
  • Derive Macros

Crates

  • async_graphql
?
Change settings

Crate async_graphql

source ·
Expand description

A GraphQL server library implemented in Rust

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

Documentation

  • Feature Comparison
  • Book
  • 中文文档
  • Docs
  • GitHub repository
  • Cargo package
  • Minimum supported Rust version: 1.56.1 or later

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(v2)
  • Batch Queries
  • Apollo Persisted Queries

Crate features

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

  • apollo_tracing: Enable the Apollo tracing extension.
  • apollo_persisted_queries: Enable the [Apollo persisted queries extension](extensions/apollo_persisted_queries/struct. ApolloPersistedQueries.html).
  • log: Enable the logger extension.
  • tracing: Enable the tracing extension.
  • opentelemetry: Enable the OpenTelemetry extension.
  • unblock: Support asynchronous reader for Upload
  • bson: Integrate with the bson crate.
  • chrono: Integrate with the chrono crate.
  • chrono-tz: Integrate with the chrono-tz crate.
  • url: Integrate with the url crate.
  • uuid: Integrate with the uuid crate.
  • uuid08: Integrate with the uuid 0.8 crate.
  • string_number: Enable the StringNumber.
  • dataloader: Support DataLoader.
  • secrecy: Integrate with the secrecy crate.
  • decimal: Integrate with the rust_decimal crate.
  • bigdecimal: Integrate with the bigdecimal crate.
  • cbor: Support for serde_cbor.
  • smol_str: Integrate with the smol_str crate.
  • hashbrown: Integrate with the hashbrown crate.
  • time: Integrate with the time crate.
  • tokio-sync: Integrate with the tokio::sync::RwLock and tokio::sync::Mutex.
  • fast_chemail: Integrate with the fast_chemail crate.
  • tempfile: Save the uploaded content in the temporary file.
  • dynamic-schema: Support dynamic schema.

Integrations

  • Poem async-graphql-poem
  • Actix-web async-graphql-actix-web
  • Warp async-graphql-warp
  • Tide async-graphql-tide
  • Rocket async-graphql-rocket
  • Axum async-graphql-axum

License

Licensed under either of

  • Apache License, Version 2.0, (./LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (./LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.

References

  • GraphQL
  • GraphQL Multipart Request
  • GraphQL Cursor Connections Specification
  • GraphQL over WebSocket Protocol
  • Apollo Tracing
  • Apollo Federation

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 extensions::ResolveFut;
pub use parser::Pos;
pub use parser::Positioned;
pub use resolver_utils::ContainerType;
pub use resolver_utils::EnumType;
pub use resolver_utils::ScalarType;
pub use context::*;
pub use types::*;

Modules

context
Query context.
dataloaderdataloader
Batch loading support, used to solve N+1 problem.
dynamicdynamic-schema
Suppport for dynamic schema
extensions
Extensions for schema
http
A helper module that supports HTTP
resolver_utils
Utilities for implementing OutputType::resolve.
types
Useful GraphQL types.

Macros

scalar
Define a scalar
value
Construct a ConstValue.

Structs

CacheControl
Cache control value
DeserializerError
This type represents errors that can occur when deserializing.
Error
An error with a message and optional extensions.
ErrorExtensionValues
Extensions to the error.
InputValueError
An error parsing an input value.
Lookahead
A selection performed by a query.
Name
A GraphQL name.
Number
Represents a JSON number, whether integer or floating point.
Request
GraphQL request.
Response
Query response
SDLExportOptions
Options for SDL export
Schema
GraphQL schema.
SchemaBuilder
Schema builder
SerializerError
This type represents errors that can occur when serializing.
ServerError
An error in a GraphQL server.
ValidationResult
Validation results.
Variables
Variables of a query.

Enums

BatchRequest
Batch support for GraphQL requests, which is either a single query, or an array of queries
BatchResponse
Response for batchable queries
IntrospectionMode
Introspection mode
ParseRequestError
An error parsing the request.
PathSegment
A segment of path to a resolver.
ValidationMode
Validation mode
Value
A resolved GraphQL value, for example 1 or "Hello World!".

Traits

CustomDirective
Represents a custom directive.
CustomValidator
Represents a custom input value validator.
ErrorExtensions
An error which can be extended into a Error.
Executor
Represents a GraphQL executor
Guard
Field guard
GuardExt
An extension trait for Guard.
InputObjectType
A GraphQL input object.
InputType
Represents a GraphQL input type.
InterfaceType
A GraphQL interface.
ObjectType
A GraphQL object.
OneofObjectType
A GraphQL oneof input object.
OutputType
Represents a GraphQL output type.
ResultExt
Extend a Result’s error value with ErrorExtensions.
SubscriptionType
A GraphQL subscription object
TypeName
Used to specify the GraphQL Type name.
UnionType
A GraphQL interface.

Functions

from_value
Interpret a ConstValue as an instance of type T.
to_value
Convert a T into ConstValue which is an enum that can represent any valid GraphQL data.

Type Definitions

FieldError
An alias of async_graphql::Error. Present for backward compatibility reasons.
FieldResult
An alias of async_graphql::Result. Present for backward compatibility reasons.
InputValueResult
An error parsing a value of type T.
Result
An alias for Result<T, Error>.
ServerResult
Alias for Result<T, ServerError>.

Attribute Macros

ComplexObject
Define a complex GraphQL object for SimpleObject’s complex field resolver.
Directive
Define a directive for query.
Object
Define a GraphQL object with methods
Scalar
Define a Scalar
Subscription
Define a GraphQL subscription

Derive Macros

Description
Attach a description to Object, Scalar or Subscription.
Enum
Define a GraphQL enum
InputObject
Define a GraphQL input object
Interface
Define a GraphQL interface
MergedObject
Define a merged object with multiple object types.
MergedSubscription
Define a merged subscription with multiple subscription types.
NewType
Define a NewType Scalar
OneofObject
Define a GraphQL oneof input object
SimpleObject
Define a GraphQL object with fields
Union
Define a GraphQL union

Results

async_graphql::to_value
Convert a T into ConstValue which is an enum that can …
async_graphql::InputType::to_value
Convert to a Value for introspection.
async_graphql::resolver_utils::ScalarType::to_value
Convert the scalar to Value.
async_graphql::types::Upload::to_value
async_graphql::types::Any::to_value
async_graphql::types::ID::to_value
async_graphql::types::Json::to_value
async_graphql::types::MaybeUndefined::to_value
async_graphql::types::StringNumber::to_value
async_graphql::Variables::into_value
Get the variables as a GraphQL value.
async_graphql::Value::into_value
Convert this ConstValue into a Value.
async_graphql::dynamic::FieldValue::try_to_value
Like as_value, but returns Result.
async_graphql::dynamic::FieldValue::as_value
If the FieldValue is a value, returns the associated …
async_graphql::types::MaybeUndefined::is_value
Returns true if the MaybeUndefined<T> contains value.
async_graphql::Value
A resolved GraphQL value, for example 1 or "Hello World!".
async_graphql::CacheControl::value
Get ‘Cache-Control’ header value.
async_graphql::dynamic::FieldValue::value
Create a FieldValue from Value
async_graphql::types::Upload::value
Get the upload value.
async_graphql::types::MaybeUndefined::value
Borrow the value, returns None if the the MaybeUndefined<T>…
async_graphql::resolver_utils::EnumItem::value
The value of the variant.
async_graphql::value
Construct a ConstValue.
async_graphql::dataloader::CacheStorage::Value
The value type of the record.
async_graphql::dataloader::Loader::Value
type of value.
async_graphql::types::MaybeUndefined::Value
async_graphql::types::MaybeUndefined::map_value
Maps a MaybeUndefined<T> to MaybeUndefined<U> by applying …
async_graphql::from_value
Interpret a ConstValue as an instance of type T.
async_graphql::Variables::from_value
Get the variables from a GraphQL value.
async_graphql::Value::eq
async_graphql::Value::fmt
async_graphql::dynamic::FieldValue::from
async_graphql::Value::clone
async_graphql::resolver_utils::ScalarType::parse
Parse a scalar value.
async_graphql::types::Any::parse
async_graphql::types::ID::parse
async_graphql::types::StringNumber::parse
async_graphql::resolver_utils::ScalarType::is_valid
Checks for a valid scalar value.
async_graphql::types::Any::is_valid
async_graphql::types::ID::is_valid
async_graphql::types::StringNumber::is_valid
async_graphql::Value::try_from
async_graphql::Response::extension
Set the extension result of the response.
async_graphql::Variables::from_json
Get the values from a JSON value.
async_graphql::Value::from_json
Attempt to convert JSON into a value. This is equivalent …
async_graphql::Value::into_json
Attempt to convert the value into JSON. This is equivalent …
async_graphql::Value::serialize
async_graphql::from_value
Interpret a ConstValue as an instance of type T.
async_graphql::Variables::from_value
Get the variables from a GraphQL value.
async_graphql::Value::into_value
Convert this ConstValue into a Value.
async_graphql::resolver_utils::parse_enum
Parse a value as an enum value.
async_graphql::resolver_utils::ContainerType::find_entity
Find the GraphQL entity with the given name from the …
async_graphql::types::connection::Connection::find_entity
async_graphql::InputValueError::expected_type
The expected input type did not match the actual input …
async_graphql::Value::deserialize_i8
async_graphql::Value::deserialize_u8
async_graphql::Value::deserialize_any
async_graphql::Value::deserialize_f32
async_graphql::Value::deserialize_f64
async_graphql::Value::deserialize_i16
async_graphql::Value::deserialize_i32
async_graphql::Value::deserialize_i64
async_graphql::Value::deserialize_map
async_graphql::Value::deserialize_seq
async_graphql::Value::deserialize_str
async_graphql::Value::deserialize_u16
async_graphql::Value::deserialize_u32
async_graphql::Value::deserialize_u64
async_graphql::Value::deserialize_bool
async_graphql::Value::deserialize_char
async_graphql::Value::deserialize_enum
async_graphql::Value::deserialize_i128
async_graphql::Value::deserialize_u128
async_graphql::Value::deserialize_unit
async_graphql::Value::deserialize_bytes
async_graphql::Value::deserialize_tuple
async_graphql::Value::into_deserializer
async_graphql::Value::is_human_readable
async_graphql::Value::deserialize_option
async_graphql::Value::deserialize_string
async_graphql::Value::deserialize_struct
async_graphql::Value::deserialize_byte_buf
async_graphql::Value::deserialize_identifier
async_graphql::Value::deserialize_ignored_any
async_graphql::Value::deserialize_unit_struct
async_graphql::Value::deserialize_tuple_struct
async_graphql::Value::deserialize_newtype_struct
async_graphql::InputType::to_value
Convert to a Value for introspection.
async_graphql::resolver_utils::ScalarType::to_value
Convert the scalar to Value.
async_graphql::types::Upload::to_value
async_graphql::types::Any::to_value
async_graphql::types::ID::to_value
async_graphql::types::Json::to_value
async_graphql::types::MaybeUndefined::to_value
async_graphql::types::StringNumber::to_value
async_graphql::Value::from
async_graphql::Value::clone
async_graphql::Value::default
async_graphql::Value::from_iter
async_graphql::resolver_utils::enum_value
Convert the enum value into a GraphQL value.
async_graphql::Variables::into_value
Get the variables as a GraphQL value.
async_graphql::Value::into_value
Convert this ConstValue into a Value.