A simple GraphQL server written in Python using pure graphql-core with FastAPI and a fully custom GraphiQL UI.
Everything runs in-memory; no database is required.
- Install dependencies:
pip install -r requirements.txt
- Start the server:
uvicorn main:app --reload
or alternatively:
python -m uvicorn main:app --reload
- Open GraphiQL UI in your browser:
| Path | Method | Description |
|---|---|---|
| "/graphql" | POST | GraphQL API endpoint |
| "/" | GET | Interactive GraphiQL UI |
{
hello
}
{
users {
id
name
email
}
}
{
user(id: "2") {
id
name
email
}
}
mutation {
sendMessage(message: "Hello world!") {
message
timestamp
}
}
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"{ hello }\"}"
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"{ users { id name email } }\"}"
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"{ user(id: \\\"2\\\") { id name email } }\"}"
curl -X POST http://localhost:8000/graphql \
-H "Content-Type: application/json" \
-d "{\"query\":\"mutation { sendMessage(message: \\\"Hello from curl\\\") { message timestamp } }\"}"
- GraphQL Queries:
hello,users,user(id: ID) - GraphQL Mutation:
sendMessage(message: String) - Interactive GraphiQL UI at
/ - Runs on FastAPI (async Python)
- Fully deployable on any Python-compatible host
- Python 3.12 — programming language
- FastAPI — lightweight, fast HTTP framework
- graphql-core — pure Python GraphQL implementation (port of GraphQL.js)
- Uvicorn — ASGI server
- GraphiQL — in-browser GraphQL IDE served manually