{"id":31783887,"url":"https://github.com/tony/learning-fastapi","last_synced_at":"2026-05-02T23:37:55.171Z","repository":{"id":317045432,"uuid":"1065771015","full_name":"tony/learning-fastapi","owner":"tony","description":"FastAPI + strawberry + uv + strict mypy typings + py.test harnessed","archived":false,"fork":false,"pushed_at":"2026-04-18T13:42:34.000Z","size":502,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-18T15:32:53.353Z","etag":null,"topics":["fastapi","graphql","mypy","pytest","python","starter","strawberry","uv"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tony.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-09-28T11:54:11.000Z","updated_at":"2026-04-18T13:42:38.000Z","dependencies_parsed_at":"2026-02-01T00:02:01.167Z","dependency_job_id":null,"html_url":"https://github.com/tony/learning-fastapi","commit_stats":null,"previous_names":["tony/learning-fastapi"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tony/learning-fastapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tony%2Flearning-fastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tony%2Flearning-fastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tony%2Flearning-fastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tony%2Flearning-fastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tony","download_url":"https://codeload.github.com/tony/learning-fastapi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tony%2Flearning-fastapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32553688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T22:28:24.418Z","status":"ssl_error","status_checked_at":"2026-05-02T22:28:14.225Z","response_time":132,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["fastapi","graphql","mypy","pytest","python","starter","strawberry","uv"],"created_at":"2025-10-10T10:56:52.752Z","updated_at":"2026-05-02T23:37:55.156Z","avatar_url":"https://github.com/tony.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learning FastAPI\n\nA compact playground that demonstrates how to serve classic HTTP routes and\nGraphQL queries with [FastAPI](https://fastapi.tiangolo.com) and\n[Strawberry GraphQL](https://strawberry.rocks). The project keeps the footprint\nsmall so you can focus on how the pieces fit together: a Strawberry schema, a\nFastAPI application with both REST and GraphQL endpoints, and a concise\npytest-based test suite.\n\n## Highlights\n\n- FastAPI application defined in `src/app/app.py` that exposes:\n  - `GET /` — synchronous route returning a plain-text greeting.\n  - `POST /graphql` — a Strawberry-powered GraphQL router mounted at `/graphql`.\n- GraphQL `Query` type uses `strawberry.Private` to store the greeting server-side\n  while exposing a typed resolver.\n- Tests built with `pytest` and `fastapi.testclient.TestClient` exercising both\n  HTTP and GraphQL flows.\n- Tooling powered by `uv`, `ruff`, and `mypy` for repeatable local workflows.\n\n## Project Layout\n\n```\nsrc/\n  app/__init__.py      # Re-exports the FastAPI app and run() helper for uvicorn\n  app/app.py           # FastAPI app, HTTP route, Strawberry schema \u0026 GraphQL router\n  app/settings.py      # Pydantic settings (host, port, reload flags)\ntests/\n  test_app.py          # End-to-end tests for the HTTP and GraphQL endpoints\npyproject.toml         # Project metadata, Ruff \u0026 mypy configuration\nuv.lock                # Reproducible dependency lock generated by uv\n```\n\n## Requirements\n\n- Python 3.14 or newer (project targets `py314`).\n- [uv](https://github.com/astral-sh/uv) 0.8+ for dependency management\n  (recommended). If you prefer `pip`, create a virtual environment manually and\n  install the dependencies via `pip install -e .` plus any tooling you need.\n\n## Getting Started\n\n```bash\n# Install dependencies (includes dev tools such as pytest, ruff, mypy)\nuv sync --all-extras --dev\n\n# Run the development server with auto-reload\nuv run uvicorn app:app --reload --host 127.0.0.1 --port 8020\n```\n\nThe server listens on \u003chttp://127.0.0.1:8020/\u003e by default (configurable via\nenvironment variables, see `src/app/settings.py`).\n\n## Available Endpoints\n\n### HTTP\n\n```\nGET /\n```\n\nExample:\n\n```bash\ncurl http://127.0.0.1:8020/\n# =\u003e Hello, world!\n```\n\n### GraphQL\n\n```\nPOST /graphql\n```\n\nQuery the schema with any GraphQL client or plain `curl`:\n\n```bash\ncurl -X POST http://127.0.0.1:8020/graphql \\\n  -H 'content-type: application/json' \\\n  -d '{\"query\": \"query { hello }\"}'\n\n# =\u003e {\"data\":{\"hello\":\"Hello World\"}}\n```\n\nThe schema lives in `Query`, and the router is provided by\n`strawberry.fastapi.GraphQLRouter`. FastAPI mounts it directly on the\napplication instance so Strawberry receives a fresh `Query` object for each\nrequest.\n\n## Quality Checks\n\n```bash\n# Tests\nuv run pytest\n\n# Ruff linting (same flags used by CI experiments)\nuv run ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes\n\n# Ruff formatting\nuv run ruff format .\n\n# Static typing\nuv run mypy .\n```\n\n## Design Notes\n\n- The GraphQL `Query` type stores its greeting on a `strawberry.Private` field,\n  keeping configuration server-side while exposing a typed resolver in the schema.\n- The HTTP handler and GraphQL resolvers remain synchronous and CPU-light, so\n  they run directly on the event loop without extra thread dispatch.\n- All configuration, tooling, and dependency metadata live in `pyproject.toml`\n  to reduce dotfile churn.\n\n## Next Steps\n\nIdeas for extending the playground:\n\n- Add mutations or subscriptions to the Strawberry schema.\n- Introduce persistence (e.g., SQLModel) and showcase FastAPI dependencies for\n  database sessions.\n- Experiment with background tasks, WebSocket endpoints, or dependency overrides.\n- Wire up a front-end (HTMX, React, etc.) and consume the GraphQL endpoint.\n\nHappy exploring FastAPI and Strawberry!\n\n## License\n\nReleased under the [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftony%2Flearning-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftony%2Flearning-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftony%2Flearning-fastapi/lists"}