{"id":19520949,"url":"https://github.com/rodneylab/axum-graphql","last_synced_at":"2026-05-06T00:05:50.688Z","repository":{"id":260290228,"uuid":"880833947","full_name":"rodneylab/axum-graphql","owner":"rodneylab","description":"Rust GraphQL demo/test API written in Rust, using Axum for routing, async-graphql and SQLx","archived":false,"fork":false,"pushed_at":"2025-02-25T08:22:22.000Z","size":2431,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T09:22:52.730Z","etag":null,"topics":["async-graphql","axum","axum-demo","graphql","graphql-api","jaeger","jaeger-tracing","metrics","observability","opentelemetry","prometheus","rust","tracing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rodneylab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-30T12:56:16.000Z","updated_at":"2025-02-25T08:21:25.000Z","dependencies_parsed_at":"2024-12-02T16:41:35.296Z","dependency_job_id":"3b2ba832-f8e2-4522-8679-d6ba82eadcec","html_url":"https://github.com/rodneylab/axum-graphql","commit_stats":null,"previous_names":["rodneylab/axum-graphql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Faxum-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Faxum-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Faxum-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rodneylab%2Faxum-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rodneylab","download_url":"https://codeload.github.com/rodneylab/axum-graphql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240769215,"owners_count":19854598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-graphql","axum","axum-demo","graphql","graphql-api","jaeger","jaeger-tracing","metrics","observability","opentelemetry","prometheus","rust","tracing"],"created_at":"2024-11-11T00:28:30.526Z","updated_at":"2026-05-06T00:05:50.682Z","avatar_url":"https://github.com/rodneylab.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg\n  src=\"./images/rodneylab-github-axum-graphql.png\"\n  alt=\"Rodney Lab Axum Graph Q L Git Hub banner\"\n/\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca\n    aria-label=\"Open Rodney Lab site\"\n    href=\"https://rodneylab.com\"\n    rel=\"nofollow no:w\n  opener noreferrer\"\n  \u003e\n    \u003cimg\n      alt=\"Rodney Lab logo\"\n      src=\"https://rodneylab.com/assets/icon.png\"\n      width=\"60\"\n    /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003ch1 align=\"center\"\u003eaxum-graphql\u003c/h1\u003e\n\n[![codecov](https://codecov.io/gh/rodneylab/axum-graphql/branch/main/graph/badge.svg?token=V9UQLFTRCJ)](https://codecov.io/gh/rodneylab/axum-graphql)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/rodneylab/axum-graphql)\n\n## Introduction\n\n**Rust GraphQL demo/test API written in Rust, using Axum for routing,\\\nasync-graphql and SQLx.**\n\nFor Rust developers building a GraphQL API, considering using Axum and\nasync-graphql.\n\nAPIs are minimal and represent a blog site back-end, with GraphQL queries to\ncreate and delete draft posts, as well as, publish them.\n\nThe app is based on\n[How to Build a Powerful GraphQL API with Rust by Oliver Jumpertz](#acknowledgements),\nupdated to use Axum 0.8. It also has more extensive observability, implemented\nusing OpenTelemetry. Data are pushed from the app to an OpenTelemetry collector,\nwhich in turn:\n\n- has a Prometheus metrics endpoint;\n- pushes traces to a Jaeger collector, which exposes a Jaeger Query UI endpoint;\n  and\n- exports logs to a Loki endpoint.\n\nOpenTelemetry collector, Prometheus, Jaeger Collector, Jaeger Query and Loki all\nget spun up via [`docker-compose`](./docker-compose.yml). Additionally, the\ndocker-compose configuration initialises a Grafana session (collecting all\npreviously mentioned observability components into a single interface).\n\n\u003cimg\n  src=\"./images/architecture.png\"\n  alt=\"App architecture shows the App at the centre, with connections to the Graph Q L Playground, Graph Q L A P I and S Q Lite Database.  There is a connection pointing downwards from the App, which connects to the otel Collector.  The otel Collector has edges leaving it, point to Prometheus, Jaeger Collector and Loki.  The last three all have connections that terminate in the Grafana node.\"\n/\u003e\n\n## Contents\n\n- [Introduction](#introduction)\n- [Spinning up the app](#spinning-up-the-app)\n  - [Prerequisites](#prerequisites)\n  - [Running the app](#running-the-app)\n- [App and Observability Endpoints](#app-and-observability-endpoints)\n- [What’s inside?](#whats-inside)\n  - [Tracing](#tracing)\n  - [SQLite Database](#sqlite-database)\n- [Why did I create this?](#why-did-i-create-this)\n- [What this is not](#what-this-is-not)\n- [Issues and Support](#️-issues-and-support)\n- [Contributions](#contributions)\n- [Acknowledgements](#acknowledgements)\n- [License](#license)\n\n## Spinning up the app\n\n### Prerequisites\n\nRequires:\n\n- Rust 1.86 toolchain or newer; and\n- docker-compose.\n\n\u003cimg\n  src=\"./images/usage.gif\"\n  alt=\"Terminal animation shows the user entering the following command: cargo run. Then the code compiles and server starts.  Status messages inform that Metrics service is listening on 127.0.0.1:8001, Migrations were run successfully, and Main app service is listening on 127.0.0.1:8000\"\n/\u003e\n\n1. Clone this repo and change into the new directory.\n\n2. Start the observability services with docker-compose:\n\n### Running the app\n\n```shell\ndocker compose up -d\n```\n\n3. Start the app with `cargo run`. The app will create the SQLite database file\n   and run database migrations in the `migrations` directory.\n\n4. Open a browser window at `http://localhost:8000` to bring up the GraphQL\n   Playground and run some queries.\n\n5. The observability services might take a few moments to spin up, and in this\n   case you will see Terminal output:\n\n```shell\nOpenTelemetry trace error occurred. Exporter otlp encountered the following error(s): the grpc server returns error (The service is currently unavailable): , detailed error message: tcp connect error: Connection refused (os error 61)\n```\n\nThis should be temporary.\n\n#### SQLite Database\n\nThe project database migrations create an SQLite database with a Post table,\nwhich has `id`, `title`, `body` and `published` fields. You can run GraphQL\nqueries to create, read, update and delete from this table.\n\n\u003cimg\n  src=\"./images/axum-graphql-sqlite-db-post-table.png\"\n  alt=\"Diagram representing database table.  The heading reads `Post`.  Below, the table columns, with associated type is listed: id (integer), title (text), body (text) and published (boolean).  A key icon appears within in the id column data, indicating id is a database primary key.\"\n/\u003e\n\n#### Example queries\n\n- Hello world:\n\n```graphql\nquery HelloQuery {\n  hello\n}\n```\n\n- Create a draft:\n\n```graphql\nmutation CreateDraftMutation {\n  createDraft(title: \"Post working title\", body: \"Draft body text\") {\n    id\n    title\n  }\n}\n```\n\n- Delete a draft:\n\n```graphql\nmutation DeleteDraftMutation {\n  deleteDraft(id: 1) {\n    __typename\n    ... on DeleteDraftSuccessResponse {\n      post {\n        id\n        title\n      }\n    }\n    ... on DeleteDraftErrorResponse {\n      error {\n        field\n        message\n        received\n      }\n    }\n  }\n}\n```\n\n- List existing drafts:\n\n```graphql\nquery DraftsQuery {\n  drafts {\n    id\n    title\n  }\n}\n```\n\n## App and Observability Endpoints\n\nGraphQL Playground: \u003chttp://localhost:8000/\u003e\n\nMetrics raw output: \u003chttp://localhost:8889/metrics\u003e\n\nJaeger Query UI: \u003chttp://localhost:16686/search\u003e\n\nGrafana: \u003chttp://localhost:3000/\u003e\n\n## What's inside?\n\n### tracing\n\nThe tracing service is provided via the OpenTelemetry Collector, Jaeger Query UI\nand a [Cassandra database](https://cassandra.apache.org/_/index.html), all\nrunning in Docker. Docker also spins up a Cassandra database for storing traces.\n\n### SQLite Database Files\n\nThe API uses an SQLite single-file database for simplicity, at\n[`sqlite.db`](./sqlite.db). This is automatically created (if it does not yet\nexist) when the app spins up.\n\n## Why did I create this?\n\nThe repo is just intended as a reference to speed up creating am Axum-based\nGraphQL API with observability features.\n\n## What this is not\n\n- A production-ready app.\n- Guide to using Axum, async-graphql or SQLx that covers every feature.\n  - To learn more about async-graphql, see:\n    - the [async-graphql docs](https://docs.rs/async-graphql/latest/async_graphql/);\n    - [async-graphql examples](https://github.com/async-graphql/examples); and\n    - [async-graphql book](https://async-graphql.github.io/async-graphql/en/index.html).\n  - Axum also has great resource, including:\n    - [axum docs](https://docs.rs/axum/latest/axum/); and\n    - [axum examples](https://github.com/tokio-rs/axum/tree/main/examples).\n  - For SQLx resources, see:\n    - [SQLx docs](https://docs.rs/sqlx/latest/sqlx/);\n    - [SQLx examples](https://github.com/launchbadge/sqlx/tree/main/examples); and\n    - [Rust SQLx basics with SQLite: super easy how-to](https://tms-dev-blog.com/rust-sqlx-basics-with-sqlite/).\n  - For a general introduction to building a web-based API in Rust,\n    [Zero to Production in Rust](https://www.zero2prod.com/index.html) is\n    marvellous.\n\n## ☎️ Issues and Support\n\nOpen an issue if something does not work as expected or if you have some\nimprovements.\n\nFeel free to jump into the\n[Rodney Lab matrix chat room](https://matrix.to/#/%23rodney:matrix.org).\n\n## Contributions\n\nContributions welcome, write a short issue with your idea, before spending to\nmuch time on more involved additions.\n\n### Contributing guidelines\n\n- Before working on a new feature it's preferable to submit a feature request\n  first and state that you'd like to implement it yourself\n- Please don't submit PRs for feature requests that are either in the\n  roadmap\u003csup\u003e[1]\u003c/sup\u003e, backlog\u003csup\u003e[2]\u003c/sup\u003e or icebox\u003csup\u003e[3]\u003c/sup\u003e\n- Avoid introducing new dependencies\n- Avoid making backwards-incompatible configuration changes\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003csup\u003e[1] [2] [3]\u003c/sup\u003e\u003c/strong\u003e\u003c/summary\u003e\n\n[1] The feature likely already has work put into it that may conflict with your\nimplementation\n\n[2] The demand, implementation or functionality for this feature is not yet clear\n\n[3] No plans to add this feature for the time being\n\n\u003c/details\u003e\n\n## Acknowledgements\n\nInspired by:\n\n- [Zero to Production in Rust](https://www.zero2prod.com/index.html); and\n- [How to Build a Powerful GraphQL API with Rust by Oliver Jumpertz](https://oliverjumpertz.com/blog/how-to-build-a-powerful-graphql-api-with-rust/).\n\n## License\n\nThe project is released under the BSD 3-Clause License — see the\n[LICENSE](./LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodneylab%2Faxum-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frodneylab%2Faxum-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frodneylab%2Faxum-graphql/lists"}