# Python GraphQL libraries

Python GraphQL libraries build GraphQL APIs that let clients ask for exactly the fields they need in one request. A code-first library generates the schema from Python classes rather than from a schema written in the GraphQL language. These libraries let web and mobile apps fetch nested data from a backend in a single round trip.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [graphql-core](#graphql-core) | 79.1M | 536 | Nov 2026 | MIT |
| [Graphene](#graphene) | 32.0M | 8.2K | Nov 2024 | MIT |
| [Strawberry](#strawberry) | 7.1M | 4.7K | Nov 2026 | MIT |
| [Ariadne](#ariadne) | 2.1M | 2.3K | Oct 2026 | BSD-3-Clause |
| [strawberry-graphql-django](#strawberry-graphql-django) | 2.0M | 504 | Nov 2026 | MIT |
| [Graphene SQLAlchemy](#graphene-sqlalchemy) | 1.1M | 986 | Jun 2020 | MIT |
| [Graphene Django](#graphene-django) | 1.1M | 4.4K | Mar 2025 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[graphql-core](#graphql-core) has the most monthly downloads in this comparison, at 79.1M.

## Capabilities

| Library | Annotation-based schema | Django model mapping |
| --- | --- | --- |
| [graphql-core](#graphql-core) | No | No |
| [Graphene](#graphene) | No | Via plugin |
| [Strawberry](#strawberry) | Yes | Via plugin |
| [Ariadne](#ariadne) | No | No |
| [strawberry-graphql-django](#strawberry-graphql-django) | Yes | Yes |
| [Graphene SQLAlchemy](#graphene-sqlalchemy) | No | No |
| [Graphene Django](#graphene-django) | No | Yes |

## Libraries

### graphql-core

[GitHub](https://github.com/graphql-python/graphql-core) · [PyPI](https://pypi.org/project/graphql-core) · [Docs](https://graphql-core-3.readthedocs.io/)

Provides explicit GraphQL schema-building and query-execution APIs.

- Downloads / mo: 79.1M
- Stars: 536
- Last release: 3.3.2
- License: MIT
- Capabilities: [From the graphql-core docs](https://graphql-core-3.readthedocs.io/)

**Strengths**

- **Exposes schema and execution primitives.** Build schema objects and execute queries directly.
- **Runs asynchronous resolvers.** Return coroutine objects from resolvers and await query execution.

**Watch out for**

- **Minor releases can break APIs.** Pin a compatible minor series when declaring the dependency.
- **Resolver arguments differ from JavaScript.** Receive GraphQL arguments as keyword arguments after the info parameter.

```sh
python -m pip install graphql-core
```

**graphql-python/gql** (1.7K stars)

[graphql-python/gql](https://github.com/graphql-python/gql) 

```python
def __init__(
    self,
    request: Union[DocumentNode, "GraphQLRequest", str],
    *,
    variable_values: Optional[Dict[str, Any]] = None,
    operation_name: Optional[str] = None,
    extensions: Optional[Dict[str, Any]] = None,
):
    """Initialize a GraphQL request.

    :param request: GraphQL request as DocumentNode object or as a string.
         If string, it will be converted to DocumentNode.
    :param variable_values: Dictionary of input parameters (Default: None).
    :param operation_name: Name of the operation that shall be executed.
        Only required in multi-operation documents (Default: None).
    :param extensions: Dictionary of protocol extensions (Default: None).
        This is passed as the top-level "extensions" key in the request
        payload, as defined in the GraphQL over HTTP spec.
    :return: a :class:`GraphQLRequest <gql.GraphQLRequest>`
             which can be later executed or subscribed by a
             :class:`Client <gql.client.Client>`, by an
             :class:`async session <gql.client.AsyncClientSession>` or by a
             :class:`sync session <gql.client.SyncClientSession>`
    :raises graphql.error.GraphQLError: if a syntax error is encountered.
    """
    if isinstance(request, str):
        source = Source(request, "GraphQL request")
        self.document = parse(source)
    elif isinstance(request, DocumentNode):
        self.document = request
    elif not isinstance(request, GraphQLRequest):
        raise TypeError(f"Unexpected type for GraphQLRequest: {type(request)}")

    if isinstance(request, GraphQLRequest):
        self.document = request.document
        if variable_values is None:
            variable_values = request.variable_values
        if operation_name is None:
            operation_name = request.operation_name
        if extensions is None:
            extensions = request.extensions

    self.variable_values: Optional[Dict[str, Any]] = variable_values
    self.operation_name: Optional[str] = operation_name
    self.extensions: Optional[Dict[str, Any]] = extensions

```

[gql/graphql_request.py](https://github.com/graphql-python/gql/blob/6ccc0cc2c27e95b19bf2871e7ec3e1b48283c6a0/gql/graphql_request.py#L10-L54) · [More projects using graphql-core →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20graphql-core%20to%20build%20GraphQL%20schemas%2C%20inspect%20resolver%20types%20and%20execute%20API%20queries&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
from graphql import (
    GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString)

schema = GraphQLSchema(
    query=GraphQLObjectType(
        name='RootQueryType',
        fields={
            'hello': GraphQLField(
                GraphQLString,
                resolve=lambda obj, info: 'world')
        }))

from graphql import graphql_sync

source = '{ hello }'

print(graphql_sync(schema, source))

```

From [README.md](https://api.github.com/repos/graphql-python/graphql-core/git/blobs/0846e5dd32ab2828fd4416367645fd859ab4a044)

### Graphene

[GitHub](https://github.com/graphql-python/graphene) · [PyPI](https://pypi.org/project/graphene)

Builds GraphQL API schemas using Python classes.

- Downloads / mo: 32.0M
- Stars: 8.2K
- Last release: 3.4.3
- License: MIT
- Capabilities: [From the Graphene docs](https://github.com/graphql-python/graphene)

**Strengths**

- **Defines schemas with Python classes.** Describe API fields in Python instead of writing SDL separately.
- **Includes Relay support.** Build Relay-compatible APIs with the bundled Relay helpers.

**Watch out for**

- **Field names change to camelCase.** Disable auto_camelcase to preserve Python field names in the schema.
- **GraphQL-core versions are constrained.** Keep GraphQL-core within the dependency range required by Graphene.

```sh
pip install "graphene>=3.1"
```

**dagster-io/dagster** (16.4K stars)

[dagster-io/dagster](https://github.com/dagster-io/dagster) 

```python
def create_schema() -> graphene.Schema:
    return graphene.Schema(
        query=GrapheneQuery,
        mutation=GrapheneMutation,
        subscription=GrapheneSubscription,
        types=types(),
    )

```

[python_modules/dagster-graphql/dagster_graphql/schema/__init__.py](https://github.com/dagster-io/dagster/blob/b0099d257d666c1c95e8079254060d2ab2caa6f3/python_modules/dagster-graphql/dagster_graphql/schema/__init__.py#L82-L88) · [More projects using Graphene →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20graphene%20to%20build%20GraphQL%20schemas%2C%20inspect%20resolver%20types%20and%20execute%20API%20queries&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import graphene

class Query(graphene.ObjectType):
    hello = graphene.String(description='A typical hello world')

    def resolve_hello(self, info):
        return 'World'

schema = graphene.Schema(query=Query)

query = '''
    query SayHello {
      hello
    }
'''
result = schema.execute(query)

```

From [README.md](https://api.github.com/repos/graphql-python/graphene/git/blobs/7beb975c2b8a3a65ea404a3889cc69f567a61ed5)

### Strawberry

[GitHub](https://github.com/strawberry-graphql/strawberry) · [PyPI](https://pypi.org/project/strawberry-graphql) · [Docs](https://pypi.org/project/strawberry-graphql/)

Builds GraphQL schemas from Python dataclasses and type annotations.

- Downloads / mo: 7.1M
- Stars: 4.7K
- Last release: 0.341.2
- License: MIT
- Capabilities: [From the Strawberry docs](https://pypi.org/project/strawberry-graphql/)

**Strengths**

- **Uses Python type annotations.** Describe field types through ordinary Python annotations.
- **Includes Apollo Federation.** Build federated services without adding a separate federation package.

**Watch out for**

- **Sync resolvers block their worker.** Use async resolvers or move blocking work into a thread.

```sh
pip install "strawberry-graphql[cli]"
```

**strawberry-graphql/strawberry-django** (504 stars)

[strawberry-graphql/strawberry-django](https://github.com/strawberry-graphql/strawberry-django) 

```python
def get_possible_type_definitions(
    gql_type: StrawberryObjectDefinition | StrawberryType | type,
) -> Generator[StrawberryObjectDefinition]:
    """Resolve all possible type definitions for gql_type.

    Args:
    ----
        gql_type:
            The type to retrieve possibilities from.

    Yields:
    ------
        All possibilities for the type

    """
    if isinstance(gql_type, StrawberryObjectDefinition):
        yield gql_type
        return

    for t in get_possible_types(gql_type):
        if isinstance(t, StrawberryObjectDefinition):
            yield t
        elif has_object_definition(t):
            yield t.__strawberry_definition__

```

[strawberry_django/utils/inspect.py](https://github.com/strawberry-graphql/strawberry-django/blob/8fc7e3b78b78d51d9aaf0161e9da0ba0d23dbabc/strawberry_django/utils/inspect.py#L134-L157) · [More projects using Strawberry →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20strawberry-graphql%20to%20build%20GraphQL%20schemas%2C%20inspect%20resolver%20types%20and%20execute%20API%20queries&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import strawberry


@strawberry.type
class User:
    name: str
    age: int


@strawberry.type
class Query:
    @strawberry.field
    def user(self) -> User:
        return User(name="Patrick", age=100)


schema = strawberry.Schema(query=Query)

```

From [README.md](https://api.github.com/repos/strawberry-graphql/strawberry/git/blobs/613af6a7c6c09e06fd9667a1beb2c59a1c58c46e)

### Ariadne

[GitHub](https://github.com/mirumee/ariadne) · [PyPI](https://pypi.org/project/ariadne) · [Docs](https://pypi.org/project/ariadne/)

Builds GraphQL servers around schemas written in SDL.

- Downloads / mo: 2.1M
- Stars: 2.3K
- Last release: 1.1.1
- License: BSD-3-Clause
- Capabilities: [From the Ariadne docs](https://pypi.org/project/ariadne/)

**Strengths**

- **Starts with SDL schemas.** Write the public schema first, then attach Python resolver functions.
- **Supports async and sync resolvers.** Use asynchronous or synchronous Python resolver functions.

**Watch out for**

- **Subscriptions need an ASGI server.** Use ASGI for WebSocket or server-sent event subscriptions.

```sh
pip install ariadne
```

**getsentry/sentry-python** (2.2K stars)

[getsentry/sentry-python](https://github.com/getsentry/sentry-python) 

```python
@ensure_integration_enabled(AriadneIntegration, old_handle_errors)
def _sentry_patched_handle_graphql_errors(
    errors: "List[GraphQLError]", *args: "Any", **kwargs: "Any"
) -> "GraphQLResult":
    result = old_handle_errors(errors, *args, **kwargs)

    event_processor = _make_response_event_processor(result[1])
    sentry_sdk.get_isolation_scope().add_event_processor(event_processor)

    client = get_client()
    if client.is_active():
        with capture_internal_exceptions():
            for error in errors:
                event, hint = event_from_exception(
                    error,
                    client_options=client.options,
                    mechanism={
                        "type": AriadneIntegration.identifier,
                        "handled": False,
                    },
                )
                capture_event(event, hint=hint)

    return result

```

[sentry_sdk/integrations/ariadne.py](https://github.com/getsentry/sentry-python/blob/7499ae7eb078337df175410d74fefc0822cab1fc/sentry_sdk/integrations/ariadne.py#L70-L93) · [More projects using Ariadne →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20ariadne%20to%20build%20GraphQL%20schemas%2C%20inspect%20resolver%20types%20and%20execute%20API%20queries&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
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)

```

From [README.md](https://api.github.com/repos/mirumee/ariadne/git/blobs/88278f63fe4389553ac86dfc9bbda6883d6b7e01)

### strawberry-graphql-django

[GitHub](https://github.com/strawberry-graphql/strawberry-django) · [PyPI](https://pypi.org/project/strawberry-graphql-django) · [Docs](https://pypi.org/project/strawberry-graphql-django/)

Extends Strawberry GraphQL for Django.

- Downloads / mo: 2.0M
- Stars: 504
- Last release: 0.96.3
- License: MIT
- Capabilities: [From the strawberry-graphql-django docs](https://pypi.org/project/strawberry-graphql-django/)

```sh
pip install strawberry-graphql-django
```

**netbox-community/netbox** (21.9K stars)

[netbox-community/netbox](https://github.com/netbox-community/netbox) 

```python
def optimize_prefetch_queryset(queryset: QuerySet, info: Info) -> QuerySet:
    """
    Apply strawberry-django's query optimizer to a queryset used inside a GenericForeignKey prefetch.
    """
    if ext := optimizer_ctx.get():
        return ext.optimize(queryset, info)

    return optimize(queryset, info)

```

[netbox/netbox/graphql/optimization.py](https://github.com/netbox-community/netbox/blob/691bb37fb891f64803eb7ec56fe5ebba287b0efe/netbox/netbox/graphql/optimization.py#L15-L22) · [More projects using strawberry-graphql-django →](https://dashboard.exa.ai/playground/search?q=strawberry-graphql-django%20GitHub%20projects)

**Quickstart**

```python
# schema.py
import strawberry
import strawberry_django
from strawberry_django.optimizer import DjangoOptimizerExtension
from .types import Fruit


@strawberry.type
class Query:
    fruits: list[Fruit] = strawberry_django.field()


schema = strawberry.Schema(
    query=Query,
    extensions=[DjangoOptimizerExtension],
)

```

From [README.md](https://api.github.com/repos/strawberry-graphql/strawberry-django/git/blobs/de9bd79d62fde734c1c5041472642f1654f4c9cc)

### Graphene SQLAlchemy

[GitHub](https://github.com/graphql-python/graphene-sqlalchemy) · [PyPI](https://pypi.org/project/graphene-sqlalchemy)

Integrates Graphene with SQLAlchemy.

- Downloads / mo: 1.1M
- Stars: 986
- Last release: 2.3.0
- License: MIT
- Capabilities: [From the Graphene SQLAlchemy docs](https://github.com/graphql-python/graphene-sqlalchemy)

```sh
pip install "graphene-sqlalchemy>=2.0"
```

**art1415926535/graphene-sqlalchemy-filter** (119 stars)

[art1415926535/graphene-sqlalchemy-filter](https://github.com/art1415926535/graphene-sqlalchemy-filter) 

```python
def __init__(
    self, connection: type[Connection], *args: Any, **kwargs: Any
) -> None:
    if self.filter_arg not in kwargs:
        model = connection._meta.node._meta.model

        with suppress(KeyError):
            kwargs[self.filter_arg] = self.filters[model]

    super().__init__(connection, *args, **kwargs)

```

[graphene_sqlalchemy_filter/connection_field.py](https://github.com/art1415926535/graphene-sqlalchemy-filter/blob/09b3343bf1a6d03645fd03a565711991b0d6e350/graphene_sqlalchemy_filter/connection_field.py#L76-L85) · [More projects using Graphene SQLAlchemy →](https://dashboard.exa.ai/playground/search?q=graphene-sqlalchemy%20GitHub%20projects)

**Quickstart**

```python
from sqlalchemy import Column, Integer, String

from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class UserModel(Base):
    __tablename__ = 'user'
    id = Column(Integer, primary_key=True)
    name = Column(String)
    last_name = Column(String)

import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType

class User(SQLAlchemyObjectType):
    class Meta:
        model = UserModel
        # use `only_fields` to only expose specific fields ie "name"
        # only_fields = ("name",)
        # use `exclude_fields` to exclude specific fields ie "last_name"
        # exclude_fields = ("last_name",)

class Query(graphene.ObjectType):
    users = graphene.List(User)

    def resolve_users(self, info):
        query = User.get_query(info)  # SQLAlchemy query
        return query.all()

schema = graphene.Schema(query=Query)

```

From [README.md](https://api.github.com/repos/graphql-python/graphene-sqlalchemy/git/blobs/9b617069a0198ec4f095af4a6b74686d3950e830)

### Graphene Django

[GitHub](https://github.com/graphql-python/graphene-django) · [PyPI](https://pypi.org/project/graphene-django)

Integrates Graphene with Django.

- Downloads / mo: 1.1M
- Stars: 4.4K
- Last release: 3.2.3
- License: MIT
- Capabilities: [From the Graphene Django docs](https://github.com/graphql-python/graphene-django)

```sh
pip install graphene-django
```

**netbox-community/netbox** (21.9K stars)

[netbox-community/netbox](https://github.com/netbox-community/netbox) 

```python
def dispatch(self, request, *args, **kwargs):
    config = get_config()

    # Enforce GRAPHQL_ENABLED
    if not config.GRAPHQL_ENABLED:
        return HttpResponseNotFound("The GraphQL API is not enabled.")

    # Attempt to authenticate the user using a DRF token, if provided
    if not request.user.is_authenticated:
        authenticator = TokenAuthentication()
        try:
            auth_info = authenticator.authenticate(request)
            if auth_info is not None:
                request.user = auth_info[0]  # User object
        except AuthenticationFailed as exc:
            return HttpResponseForbidden(exc.detail)

    # Enforce LOGIN_REQUIRED
    if settings.LOGIN_REQUIRED and not request.user.is_authenticated:

        # If this is a human user, send a redirect to the login page
        if self.request_wants_html(request):
            return redirect_to_login(reverse('graphql'))

        return HttpResponseForbidden("No credentials provided.")

    return super().dispatch(request, *args, **kwargs)

```

[netbox/netbox/graphql/views.py](https://github.com/netbox-community/netbox/blob/be903a64a2f5e2b6d070ac40adbff13197656242/netbox/netbox/graphql/views.py#L18-L44) · [More projects using Graphene Django →](https://dashboard.exa.ai/playground/search?q=graphene-django%20GitHub%20projects)

**Quickstart**

```python
import graphene
from graphene_django import DjangoObjectType
from .models import MyModel

class MyModelType(DjangoObjectType):
    class Meta:
        model = MyModel

class Query(graphene.ObjectType):
    mymodels = graphene.List(MyModelType)

    def resolve_mymodels(self, info, **kwargs):
        return MyModel.objects.all()

schema = graphene.Schema(query=Query)

```

From [README.md](https://api.github.com/repos/graphql-python/graphene-django/git/blobs/686f5ec0de4cd88a98bfbd67d7d04451be2cc053)

## FAQ

### Which Python GraphQL library should I use?

[Strawberry](#strawberry) suits new APIs built from dataclasses and type annotations. [Graphene](#graphene) suits code-first APIs with existing Django or SQLAlchemy integrations. [Ariadne](#ariadne) suits teams that write the schema first in SDL.

### How do I build a GraphQL server in Python?

Define a schema with [Strawberry](#strawberry) types, [Graphene](#graphene) classes, or an SDL string for [Ariadne](#ariadne), then bind resolvers to its fields. Each framework serves the schema through an ASGI or WSGI integration.

### What is Graphene Django?

[Graphene Django](#graphene-django) generates Graphene types from Django models and serves them through a Django GraphQL view.

### What is graphql-core?

[graphql-core](#graphql-core) is the low-level GraphQL type system, parser, validator, and executor for Python. Higher-level frameworks such as Graphene and Strawberry run on top of it.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Python GraphQL libraries Graphene Strawberry Ariadne graphql-core schema-first code-first async subscriptions federation code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
