Skip to main content

Ariadne is a Python library for implementing GraphQL servers.

Project description

Ariadne

Documentation codecov PyPI - Version PyPI - Downloads PyPI - Python Version


Ariadne

Ariadne is a Python library for implementing GraphQL servers.

  • Schema-first: Ariadne enables Python developers to use schema-first approach to the API implementation. This is the leading approach used by the GraphQL community and supported by dozens of frontend and backend developer tools, examples, and learning resources. Ariadne makes all of this immediately available to you and other members of your team.
  • Simple: Ariadne offers small, consistent and easy to memorize API that lets developers focus on business problems, not the boilerplate.
  • Open: Ariadne was designed to be modular and open for customization. If you are missing or unhappy with something, extend or easily swap with your own.

Documentation is available here.

Ariadne ecosystem

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.

Features

  • Simple, quick to learn and easy to memorize API.
  • Queries, mutations and input types.
  • Asynchronous resolvers and query execution.
  • Subscriptions (async and sync generators, with customizable handlers).
  • Custom scalars, enums and schema directives.
  • Unions and interfaces.
  • File uploads.
  • Defining schema using SDL strings.
  • Loading schema from .graphql, .gql, and .graphqls files.
  • ASGI and WSGI support, with integrations for Django, FastAPI, Flask, and Starlette.
  • Opt-in automatic resolvers mapping between camelCase123 and snake_case_123.
  • Automated integration with SQLAlchemy 2.0 for zero-boilerplate resolvers and N+1 prevention.
  • OpenTelemetry extension for API monitoring.
  • Built-in GraphiQL explorer for development and testing.
  • GraphQL syntax validation via gql() helper function.
  • No global state or object registry, support for multiple GraphQL APIs in same codebase with explicit type reuse.
  • Support for Apollo Federation.

Installation

Ariadne can be installed with pip:

pip install ariadne

Ariadne requires Python 3.10 or higher (up to 3.14).

Quickstart

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.

Versioning policy

ariadne follows Semantic Versioning.

Contributing

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

Crafted with ❤️ by Mirumee Software ariadne@mirumee.com

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ariadne-1.1.0.dev1.tar.gz (88.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ariadne-1.1.0.dev1-py3-none-any.whl (124.0 kB view details)

Uploaded Python 3

File details

Details for the file ariadne-1.1.0.dev1.tar.gz.

File metadata

  • Download URL: ariadne-1.1.0.dev1.tar.gz
  • Upload date:
  • Size: 88.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ariadne-1.1.0.dev1.tar.gz
Algorithm Hash digest
SHA256 ace3ccd254fc02b0b8013d11b8e36b0268ae2f773ed4bda14685bdbd6a7c4351
MD5 228c52051e809381576e314d25413ef9
BLAKE2b-256 76a38f61c17373646f9fe8007f720e186b27f68ac56b1addcce6186686be220e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ariadne-1.1.0.dev1.tar.gz:

Publisher: publish.yml on mirumee/ariadne

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ariadne-1.1.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: ariadne-1.1.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 124.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ariadne-1.1.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb2522903f491917e9bdea46adca717028097ec59f4c44c718b5361223d03f79
MD5 2fb199bfa9c329b00433b3127d6a992d
BLAKE2b-256 c8543775bcc54b9d3e049d8635b58a1ab90ce1acd0ff53b33f8464f867a7a6e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for ariadne-1.1.0.dev1-py3-none-any.whl:

Publisher: publish.yml on mirumee/ariadne

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page