| title | SQLite GraphQL quickstart |
|---|---|
| kind | reference |
| status | active |
| owner | graphql-orm-maintainers |
| last_reviewed | 2026-08-12 |
| review_by | 2027-02-01 |
| supersedes |
In a few minutes, run a local GraphQL service that derives its schema and
repository helpers from one Rust struct. The canonical source is
crates/graphql-orm/examples/sqlite_quickstart.rs;
the commands below execute and test that exact file.
Clone the documentation/example snapshot and run its smoke test before starting the server. This is the first commit that contains the quickstart; it is intentionally separate from the package dependency release pin below.
git clone https://github.com/Dastari/graphql-orm.git
cd graphql-orm
git checkout f88306d4fb9f2524f38886df3b316155122e89ff
cargo test -p graphql-orm --example sqlite_quickstart
cargo run -p graphql-orm --example sqlite_quickstartThe server listens only on 127.0.0.1:3000 and writes quickstart.db in the
current directory. In a second terminal, issue a GraphQL request:
curl http://127.0.0.1:3000/graphql \
--header 'content-type: application/json' \
--data '{"query":"{ tasks { edges { node { title completed } } pageInfo { totalCount } } }"}'It returns two seeded tasks, including Learn graphql-orm and Run the quickstart, with totalCount: 2.
The Task entity
uses GraphQLEntity and GraphQLOperations. schema_roots! creates the
generated query and mutation roots. At startup, the example:
- connects a SQLite
DatabasewithSchemaPolicy::Managed; - explicitly plans and applies the initial
tasksmigration; - inserts two rows with generated
Task::insert_manyhelpers; - builds the generated async-graphql schema; and
- serves
POST /graphqlandGET /healththrough Axum.
The embedded smoke test builds an in-memory database and executes the same
generated tasks query. Keep application examples close to this shape so the
test and the published guidance cannot silently drift apart.
Copy the canonical source into your application and give it these direct
dependencies. This is the package dependency release pin for graphql-orm
0.21.0 (fac98d99e64c841a34d2d0096cdf928c3f9a7c6f), not the repository
snapshot used above to run the checked-in example. Review and update it
deliberately when upgrading.
[dependencies]
async-graphql = "7"
axum = "0.8.9"
graphql-orm = { git = "https://github.com/Dastari/graphql-orm.git", rev = "fac98d99e64c841a34d2d0096cdf928c3f9a7c6f", version = "0.21.0", default-features = false, features = ["sqlite"] }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] }The source uses no application-specific names or framework adapter beyond
Axum. You can replace the HTTP layer while keeping the explicit connection,
migration, seed, and schema_builder steps.
The example deliberately declares auth: "none" at both the entity and root
level, so a newcomer can make a local request without credentials. That is an
explicit public-demo choice, not a production recommendation. Before binding a
real service beyond a local interface, provide application-owned
authentication, authorization and row/field policy, request limits, transport
security, error handling, observability, and an appropriate migration process.
Read authentication and authorization
and operation assurance before
exposing mutations.