Generate fully typed Python client for any GraphQL API from schema, queries and mutations
Python
406
993 commits
updated Oct 6, 2026
Python code generator that turns a GraphQL schema and your operations into a fully typed, async (or sync) Python client built on Pydantic. You write your queries, mutations and subscriptions in GraphQL, and ariadne-codegen generates a typed Python method for each one, returning Pydantic models - so you get autocompletion and static type checking instead of hand-writing query strings and parsing raw JSON.
📖 Documentation · Step-by-step example · Configuration reference
graphql-transport-ws).serialize/parse hooks.httpx/websockets deps).Requires Python 3.10 or newer.
pip install ariadne-codegen
Add subscription (WebSocket) support with:
pip install ariadne-codegen[subscriptions]
Generate a typed client from three files.
1. Describe your schema in schema.graphql:
type Query {
hello(name: String!): String!
}
2. Write the operations you need in queries.graphql:
query Greet($name: String!) {
hello(name: $name)
}
3. Point ariadne-codegen at them in pyproject.toml:
[tool.ariadne-codegen]
schema_path = "schema.graphql"
queries_path = "queries.graphql"
Then generate the client:
ariadne-codegen
This creates a graphql_client package. Use it:
import asyncio
from graphql_client import Client
async def main():
async with Client(url="https://example.com/graphql") as client:
result = await client.greet(name="World")
print(result.hello)
asyncio.run(main())
greet is a typed method generated from your Greet operation, and result is a
validated Pydantic model. See the step-by-step example
for a walk-through of everything that gets generated.
Contributions are welcome! See CONTRIBUTING.md for how to report bugs, work on issues, and open pull requests.
Also make sure you follow @AriadneGraphQL on Twitter for latest updates, news and random musings!
2,715 followers · starred Feb 2023
1,941 followers · starred Mar 2025
45 followers · starred Dec 2022
807 followers · starred Feb 2023
Generate fully typed Python client for any GraphQL API from schema, queries and mutations
Python
406
993 commits
updated Oct 6, 2026
Python code generator that turns a GraphQL schema and your operations into a fully typed, async (or sync) Python client built on Pydantic. You write your queries, mutations and subscriptions in GraphQL, and ariadne-codegen generates a typed Python method for each one, returning Pydantic models - so you get autocompletion and static type checking instead of hand-writing query strings and parsing raw JSON.
📖 Documentation · Step-by-step example · Configuration reference
graphql-transport-ws).serialize/parse hooks.httpx/websockets deps).Requires Python 3.10 or newer.
pip install ariadne-codegen
Add subscription (WebSocket) support with:
pip install ariadne-codegen[subscriptions]
Generate a typed client from three files.
1. Describe your schema in schema.graphql:
type Query {
hello(name: String!): String!
}
2. Write the operations you need in queries.graphql:
query Greet($name: String!) {
hello(name: $name)
}
3. Point ariadne-codegen at them in pyproject.toml:
[tool.ariadne-codegen]
schema_path = "schema.graphql"
queries_path = "queries.graphql"
Then generate the client:
ariadne-codegen
This creates a graphql_client package. Use it:
import asyncio
from graphql_client import Client
async def main():
async with Client(url="https://example.com/graphql") as client:
result = await client.greet(name="World")
print(result.hello)
asyncio.run(main())
greet is a typed method generated from your Greet operation, and result is a
validated Pydantic model. See the step-by-step example
for a walk-through of everything that gets generated.
Contributions are welcome! See CONTRIBUTING.md for how to report bugs, work on issues, and open pull requests.
Also make sure you follow @AriadneGraphQL on Twitter for latest updates, news and random musings!
2,715 followers · starred Feb 2023
1,941 followers · starred Mar 2025
45 followers · starred Dec 2022
807 followers · starred Feb 2023