page:recipes:graphql api:axum:persistent state

Host GraphQL API with Axum: Postgres-backed state

Summary

Deploy a GraphQL API built with Axum on Ample using the durable job state pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, and a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL. Verified on Axum: a jobs table with a state and attempts counter, processing inside a row-locked transaction, and a second run that is a no-op (job=done attempts=1 idempotent=true). Not separately tested: your job types, payload schema, and retry policy; treat the GraphQL API-specific behavior as your application code.

Representative Queries

Resource Requirements

Infrastructure Requirements

Framework

Axum

Workload

GraphQL API

Release Status

Published

Support Status

Verified

Execution Status

Ready

Prerequisites

  1. An Axum project that builds and starts with the documented commands (cargo build --release in the rust builder image (stable toolchain, Cargo.lock committed, pure-Rust dependencies), then the release binary on the ubuntu-24.04 template reading PORT and DATABASE_URL).
  2. A PostgreSQL driver reading DATABASE_URL at runtime (auto-provisioned when omitted or supplied with --env).
  3. An Ample account token with servers:write, databases:read.

Tested Configuration

Workflow Steps

  1. Build and start: cargo build --release in the rust builder image.
  2. Implement the pattern on PostgreSQL: Ensure durable job state with a jobs table and state counter.
  3. Deploy: Run the synchronous deploy once and read the result.
    • Command: ample deploy . --name --public
  4. Verify: Fetch the live URL and pattern self-test route(s) and run checks.
    • Command: ample logs --kind build

Examples

Success Checks

  1. App responds on its public URL
    • Kind: http_get
    • Path: /
    • Expect: ample canary axum patterns
  2. Durable-job-state self-test
    • Kind: http_get
    • Path: /p/durable-job-state
    • Expect: job=done attempts=1 idempotent=true

Limitations

Cost Estimate

Evidence Summary

Unknowns

Formats