Python library for implementing GraphQL servers using schema-first approach. Created with ❤️ by Mirumee
See the codeAriadne is a Python library for implementing GraphQL servers.
Documentation is available here.
| Repository | Description |
|---|---|
| Ariadne | Python library for implementing GraphQL servers using a schema-first approach. |
| Ariadne codegen | GraphQL client code generator for Python. |
| Ariadne auth | A collection of authentication and authorization utilities for Ariadne. |
| Ariadne lambda | Deploy Ariadne GraphQL applications as AWS Lambda functions. |
| Ariadne GraphQL proxy | A GraphQL proxy for Ariadne that allows you to combine multiple GraphQL APIs into a single API. |
.graphql, .gql, and .graphqls files.camelCase123 and snake_case_123.gql() helper function.Ariadne can be installed with pip:
pip install ariadne
Ariadne requires Python 3.10 or higher (up to 3.14).
The following example creates an API defining Person type and single query field people returning a list of two persons. It also starts a local dev server with GraphiQL available on the http://127.0.0.1:8000 address.
Start by installing uvicorn, an ASGI server we will use to serve the API:
pip install uvicorn
Then create an example.py file for your example application:
from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL
# Define types using Schema Definition Language (https://graphql.org/learn/schema/)
# Wrapping string in gql function provides validation and better error traceback
type_defs = gql("""
type Query {
people: [Person!]!
}
type Person {
firstName: String
lastName: String
age: Int
fullName: String
}
""")
# Map resolver functions to Query fields using QueryType
query = QueryType()
# Resolvers are simple python functions
@query.field("people")
def resolve_people(*_):
return [
{"firstName": "John", "lastName": "Doe", "age": 21},
{"firstName": "Bob", "lastName": "Boberson", "age": 24},
]
# Map resolver functions to custom type fields using ObjectType
person = ObjectType("Person")
@person.field("fullName")
def resolve_person_fullname(person, *_):
return "%s %s" % (person["firstName"], person["lastName"])
# Create executable GraphQL schema
schema = make_executable_schema(type_defs, query, person)
# Create an ASGI app using the schema, running in debug mode
app = GraphQL(schema, debug=True)
Finally run the server:
uvicorn example:app
For more guides and examples, please see the documentation.
ariadne follows Semantic Versioning.
We are welcoming contributions to Ariadne! If you've found a bug or issue, feel free to use GitHub issues. If you have any questions or feedback, don't hesitate to catch us on GitHub discussions.
For guidance and instructions, please see CONTRIBUTING.md.
Website and the docs have their own GitHub repository: mirumee/ariadne-website
Ariadne GraphQL is brought to you by Mirumee.
Mirumee is an Agent-Native Engineering Lab with 15+ years of experience in delivering technologies. We provide the architectural expertise needed to build critical systems for Commerce and MedTech. Scaling a complex platform? Consult us.
Created with ❤️ by Mirumee
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
(top 24 of 32)
1,852 followers · starred Mar 2021
2,324 followers · starred Jan 2019
4,433 followers · starred May 2019
624 followers · starred Apr 2020
Python library for implementing GraphQL servers using schema-first approach. Created with ❤️ by Mirumee
See the codeAriadne is a Python library for implementing GraphQL servers.
Documentation is available here.
| Repository | Description |
|---|---|
| Ariadne | Python library for implementing GraphQL servers using a schema-first approach. |
| Ariadne codegen | GraphQL client code generator for Python. |
| Ariadne auth | A collection of authentication and authorization utilities for Ariadne. |
| Ariadne lambda | Deploy Ariadne GraphQL applications as AWS Lambda functions. |
| Ariadne GraphQL proxy | A GraphQL proxy for Ariadne that allows you to combine multiple GraphQL APIs into a single API. |
.graphql, .gql, and .graphqls files.camelCase123 and snake_case_123.gql() helper function.Ariadne can be installed with pip:
pip install ariadne
Ariadne requires Python 3.10 or higher (up to 3.14).
The following example creates an API defining Person type and single query field people returning a list of two persons. It also starts a local dev server with GraphiQL available on the http://127.0.0.1:8000 address.
Start by installing uvicorn, an ASGI server we will use to serve the API:
pip install uvicorn
Then create an example.py file for your example application:
from ariadne import ObjectType, QueryType, gql, make_executable_schema
from ariadne.asgi import GraphQL
# Define types using Schema Definition Language (https://graphql.org/learn/schema/)
# Wrapping string in gql function provides validation and better error traceback
type_defs = gql("""
type Query {
people: [Person!]!
}
type Person {
firstName: String
lastName: String
age: Int
fullName: String
}
""")
# Map resolver functions to Query fields using QueryType
query = QueryType()
# Resolvers are simple python functions
@query.field("people")
def resolve_people(*_):
return [
{"firstName": "John", "lastName": "Doe", "age": 21},
{"firstName": "Bob", "lastName": "Boberson", "age": 24},
]
# Map resolver functions to custom type fields using ObjectType
person = ObjectType("Person")
@person.field("fullName")
def resolve_person_fullname(person, *_):
return "%s %s" % (person["firstName"], person["lastName"])
# Create executable GraphQL schema
schema = make_executable_schema(type_defs, query, person)
# Create an ASGI app using the schema, running in debug mode
app = GraphQL(schema, debug=True)
Finally run the server:
uvicorn example:app
For more guides and examples, please see the documentation.
ariadne follows Semantic Versioning.
We are welcoming contributions to Ariadne! If you've found a bug or issue, feel free to use GitHub issues. If you have any questions or feedback, don't hesitate to catch us on GitHub discussions.
For guidance and instructions, please see CONTRIBUTING.md.
Website and the docs have their own GitHub repository: mirumee/ariadne-website
Ariadne GraphQL is brought to you by Mirumee.
Mirumee is an Agent-Native Engineering Lab with 15+ years of experience in delivering technologies. We provide the architectural expertise needed to build critical systems for Commerce and MedTech. Scaling a complex platform? Consult us.
Created with ❤️ by Mirumee
Overall
Maintained
Code review
PyPI
Latest release
Releases this year
(top 24 of 32)
1,852 followers · starred Mar 2021
2,324 followers · starred Jan 2019
4,433 followers · starred May 2019
624 followers · starred Apr 2020