[−][src]Crate async_graphql
A GraphQL server library implemented in Rust
Documentation
- Feature Comparison
- Book
- 中文文档
- Docs
- GitHub repository
- Cargo package
- Minimum supported Rust version: 1.42 or later
Features
- Fully supports async/await
- Type safety
- Rustfmt friendly (Procedural Macro)
- Custom scalars
- Minimal overhead
- Easy integration (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 activated by default:
apollo_tracing
: Enable the Apollo tracing extension.apollo_persisted_queries
: Enable the Apollo persisted queries extension.log
: Enable the logger extension.tracing
: Enable the tracing extension.multipart
: Support sending files over HTTP multipart.unblock
: Support asynchronous reader for Uploadbson
: Integrate with thebson
crate.chrono
: Integrate with thechrono
crate.chrono-tz
: Integrate with thechrono-tz
crate.url
: Integrate with theurl
crate.uuid
: Integrate with theuuid
crate.
Integrations
- Actix-web async-graphql-actix_web
- Warp async-graphql-warp
- Tide async-graphql-tide
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
If you are just getting started, we recommend checking out our examples at: https://github.com/async-graphql/examples
To see how you would create a Relay-compliant server using async-graphql, warp, diesel & postgresql, you can also check out a real-world example at: https://github.com/phated/twentyfive-stars
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 parser::Pos; |
pub use parser::Positioned; |
pub use types::*; |
Modules
extensions | Extensions for schema |
guard | Field guards |
http | A helper module that supports HTTP |
resolver_utils | Utilities for implementing
|
types | Useful GraphQL types. |
validators | Input value validators |
Macros
scalar | Define a scalar |
value | Construct a |
Structs
CacheControl | Cache control values |
ContextBase | Query context |
Data | Schema/Context data. |
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. |
QueryPathNode | The query path node |
Request | GraphQL request. |
ResolveId | Represents the unique id of the resolve |
Response | Query response |
Schema | GraphQL schema. |
SchemaBuilder | Schema builder |
SerializerError | This type represents errors that can occur when serializing. |
ServerError | An error in a GraphQL server. |
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 |
ParseRequestError | An error parsing the request. |
PathSegment | A segment of path to a resolver. |
QueryPathSegment | The query path segment |
ValidationMode | Validation mode |
Value | A resolved GraphQL value, for example |
Traits
ContainerType | Represents a GraphQL container object. |
EnumType | A GraphQL enum. |
ErrorExtensions | An error which can be extended into a |
InputObjectType | A GraphQL input object. |
InputValueType | Represents a GraphQL input value. |
InterfaceType | A GraphQL interface. |
ObjectType | A GraphQL object. |
OutputValueType | Represents a GraphQL output value. |
ResultExt | Extend a |
ScalarType | A GraphQL scalar. |
Type | Represents a GraphQL type. |
UnionType | A GraphQL interface. |
Functions
from_value | Interpret a |
to_value | Convert a |
Type Definitions
Context | Context object for resolve field |
FieldError | An alias of async_graphql::Error. |
FieldResult | An alias of async_graphql::Result. |
InputValueResult | An error parsing a value of type |
Result | An alias for |
ServerResult | Alias for |
Attribute Macros
Object | Define a GraphQL object with methods |
Scalar | Define a Scalar |
Subscription | Define a GraphQL subscription |
Derive Macros
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. |
SimpleObject | Define a GraphQL object with fields |
Union | Define a GraphQL union |