Expand description
Production-grade GraphQL for Autumn.
Mount any async-graphql schema on an Autumn app with one line, and get the operational surface a public or internal API needs:
ⓘ
use autumn_plugin_graphql::GraphqlPlugin;
#[autumn_web::main]
async fn main() {
autumn_web::app()
.plugin(GraphqlPlugin::new(Schema::build(Query, Mutation, Subscription).finish()))
.run()
.await;
}| Concern | What you get |
|---|---|
| Transports | POST/GET per GraphQL-over-HTTP (incl. application/graphql-response+json status semantics), opt-in batching, opt-in multipart uploads, WebSocket (graphql-transport-ws + legacy graphql-ws), SSE |
| Hardening | size, lexical-nesting, depth, alias, root-field, field-count and directive limits before execution; mutations refused over GET; introspection and SDL off outside dev; CSRF preflight for multipart; execution timeouts; connection caps |
| Persisted operations | Apollo APQ with a pluggable store, and trusted documents (safelisting) from an Apollo manifest |
| Errors | stable extensions.code on every error; AutumnError mapping with 5xx redaction; masking of uncoded resolver errors |
| Context | AppState + GraphqlRequestInfo in every resolver; hooks that run any axum extractor (current user, tenant, DataLoaders); WebSocket connection_init auth |
| Operations | [graphql] config with profile layering and AUTUMN_GRAPHQL__* overrides; kill switch; Prometheus metrics; tracing spans; slow-operation log; graceful WebSocket/SSE shutdown |
| Framework fit | declared routes for autumn routes / audit, a PluginContract, a guard seam for nested routers, conformance-tested |
Every transport — HTTP, WebSocket and SSE — goes through the same
pipeline, so no path reaches the schema without the same checks.
See the crate README for a guided tour, and docs/ for architecture
decision records.
Re-exports§
pub use config::GraphqlConfig;pub use config::PersistedQueryMode;pub use config::Toggle;pub use context::ContextHook;pub use context::GraphqlRequestInfo;pub use context::Transport;pub use context::WsInitHook;pub use error::GraphqlResultExt;pub use error::IntoGraphqlError;pub use error::codes;pub use persisted::InMemoryPersistedQueryStore;pub use persisted::PersistedQueryStore;pub use persisted::TrustedDocuments;pub use async_graphql;
Modules§
- config
- The plugin-owned
[graphql]section ofautumn.toml. - context
- What every resolver can read from its
async_graphql::Context. - error
- Error vocabulary and mapping.
- limits
- Static analysis of GraphQL documents, enforced before execution.
- persisted
- Persisted operations: Automatic Persisted Queries (APQ) and trusted documents.
- pipeline
- The request pipeline every transport shares.
- sdl
- Keep a committed SDL file in step with the live schema.
Structs§
- Drain
Handle - Closes every WebSocket and SSE stream an endpoint holds.
- Graphql
Plugin - Mounts an async-graphql schema (or any
Executor) on an Autumn app.
Constants§
- CLOSE_
FORBIDDEN - Close code for a refused
connection_init(graphql-transport-ws). - CLOSE_
GOING_ AWAY - Close code for “going away” (server shutdown).
- CLOSE_
INIT_ TIMEOUT - Close code for a client that did not initialise in time.
- PLUGIN_
NAME - Name this plugin reports in its contract, in
autumn routes, and inautumn plugin-checkoutput. - SUPPORTED_
AUTUMN_ WEB - The
autumn-webseries this release is verified against, as the semver requirement declared inPlugin::contract. Autumn’s startup gate andautumn plugin-checkrefuse any other series.