Skip to main content

Crate autumn_plugin_graphql

Crate autumn_plugin_graphql 

Source
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;
}
ConcernWhat you get
TransportsPOST/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
Hardeningsize, 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 operationsApollo APQ with a pluggable store, and trusted documents (safelisting) from an Apollo manifest
Errorsstable extensions.code on every error; AutumnError mapping with 5xx redaction; masking of uncoded resolver errors
ContextAppState + 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 fitdeclared 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 of autumn.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§

DrainHandle
Closes every WebSocket and SSE stream an endpoint holds.
GraphqlPlugin
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 in autumn plugin-check output.
SUPPORTED_AUTUMN_WEB
The autumn-web series this release is verified against, as the semver requirement declared in Plugin::contract. Autumn’s startup gate and autumn plugin-check refuse any other series.