/python-ts-graphql-demo

Demo project to demonstrate how an asyncio Python project with SQLAlchemy and Strawberry can have a great typed DX on the frontend via codegen and TypeScript React hooks.

Primary LanguageTypeScript

This is a mini version of the Inch tech stack that has a Python asyncio backend querying with SQLAlchemy and Strawberry serving GraphQL with Starlette. The schema is monitored by codegen that creates urql TypeScript hooks. The goal was to have strong data consistency between the backend and frontend. Another benefit is a great VS Code environment that highlights any potential errors when communicating with the backend.

Getting started

Install Python and NPM packages

poetry install
npm i

Drop and recreate all database tables

poetry run python models.py

Run the Python GraphQL backend on port :8000 - Next.js will reverse proxy /graphql to here

poetry run uvicorn app:app --reload --host '::'

Start the GraphQL server

npm run codegen --watch

Run the frontend

npm run dev