Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A GraphQL server library implemented in Rust

License

Apache-2.0, MIT licenses found

Licenses found

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

async-graphql/async-graphql

 
 

Repository files navigation

a high-performance graphql server library that's fully specification compliant

Book中文文档DocsGitHub repositoryCargo package


ci statuscode coverageUnsafe Rust forbiddenCrates.io versiondocs.rs docsdownloadsPRs Welcome

This crate uses#![forbid(unsafe_code)] to ensure everything is implemented in 100% safe Rust.

Static schema

use std::error::Error;use async_graphql::{http::GraphiQLSource,EmptyMutation,EmptySubscription,Object,Schema};use async_graphql_poem::*;use poem::{listener::TcpListener, web::Html,*};structQuery;#[Object]implQuery{asyncfnhowdy(&self) ->&'staticstr{"partner"}}#[handler]asyncfngraphiql() ->implIntoResponse{Html(GraphiQLSource::build().finish())}#[tokio::main]asyncfnmain() ->Result<(),Box<dynError>>{// create the schemalet schema =Schema::build(Query,EmptyMutation,EmptySubscription).finish();// start the http serverlet app =Route::new().at("/",get(graphiql).post(GraphQL::new(schema)));println!("GraphiQL: http://localhost:8000");Server::new(TcpListener::bind("0.0.0.0:8000")).run(app).await?;Ok(())}

Dynamic schema

Requires thedynamic-schema feature to be enabled.

use std::error::Error;use async_graphql::{dynamic::*, http::GraphiQLSource};use async_graphql_poem::*;use poem::{listener::TcpListener, web::Html,*};#[handler]asyncfngraphiql() ->implIntoResponse{Html(GraphiQLSource::build().finish())}#[tokio::main]asyncfnmain() ->Result<(),Box<dynError>>{let query =Object::new("Query").field(Field::new("howdy",TypeRef::named_nn(TypeRef::STRING),        |_|FieldFuture::new(async{"partner"}),));// create the schemalet schema =Schema::build(query,None,None).register(query).finish()?;// start the http serverlet app =Route::new().at("/",get(graphiql).post(GraphQL::new(schema)));println!("GraphiQL: http://localhost:8000");Server::new(TcpListener::bind("0.0.0.0:8000")).run(app).await?;Ok(())}

Features

  • Static and dynamic schemas are fully supported
  • Fully supports async/await
  • Type safety
  • Rustfmt friendly (Procedural Macro)
  • Custom scalars
  • Minimal overhead
  • Easy integration (poem,axum,actix-web,tide,warp,rocket ...)
  • Upload files (Multipart request)
  • Subscriptions (WebSocket transport)
  • Custom extensions
  • Error extensions
  • Limit query complexity/depth
  • Batch queries
  • Apollo Persisted Queries
  • Apollo Tracing extension
  • Apollo Federation(v2)

Note: Minimum supported Rust version: 1.75.0 or later

Examples

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

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

For more information, see thesub-repository README.md.

Integrations

Integrations are what glueasync-graphql with your web server, here are provided ones, or you can build your own!

Crate features

This crate offers the following features. Most are not activated by default, except the integrations of GraphiQL (graphiql) and GraphQL Playground (playground):

featureenables
apollo_tracingEnable theApollo tracing extension.
apollo_persisted_queriesEnable theApollo persisted queries extension.
logEnable theLogger extension.
tracingEnable theTracing extension.
opentelemetryEnable theOpenTelemetry extension.
unblockSupportAsynchronous reader for Upload
bsonIntegrate with thebson crate.
chronoIntegrate with thechrono crate.
chrono-tzIntegrate with thechrono-tz crate.
urlIntegrate with theurl crate.
uuidIntegrate with theuuid crate.
string_numberEnable theStringNumber.
dataloaderSupportDataLoader.
secrecyIntegrate with thesecrecy crate.
decimalIntegrate with therust_decimal crate.
bigdecimalIntegrate with thebigdecimal crate.
cborSupport forserde_cbor.
smol_strIntegrate with thesmol_str crate.
hashbrownIntegrate with thehashbrown crate.
timeIntegrate with thetime crate.
tokio-syncIntegrate with thetokio::sync::RwLock andtokio::sync::Mutex.
fast_chemailIntegrate with thefast_chemail crate.
tempfileSave the uploaded content in the temporary file.
dynamic-schemaSupport dynamic schema
graphiqlEnables theGraphiQL IDE integration
playgroundEnables theGraphQL playground IDE integration

Observability

One of the tools used to monitor your graphql server in production is Apollo Studio. Apollo Studio is a cloud platform that helps you build, monitor, validate, and secure your organization's data graph.Add the extension crateasync_graphql_apollo_studio_extension to make this avaliable.

Who's usingasync-graphql in production?

Community Showcase

  • rust-actix-graphql-sqlx-postgresqlUsing GraphQL with Rust and Apollo Federation
  • entity-rs A simplistic framework based on TAO, Facebook's distributed database for Social Graph.
  • vimwiki-server Provides graphql server to inspect and manipulate vimwiki files.
  • Diana Diana is a GraphQL system for Rust that's designed to work as simply as possible out of the box, without sacrificing configuration ability.
  • cindythink
  • sudograph

Blog Posts

References

License

Licensed under either of

About

A GraphQL server library implemented in Rust

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Security policy

Stars

Watchers

Forks

Sponsor this project

 

[8]ページ先頭

©2009-2025 Movatter.jp