Python GraphQL libraries

Updated Nov 2026

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

graphql-core has the most monthly downloads in this comparison, at 79.1M.

LibraryMonthly downloadsStarsLast releaseLicense
graphql-core
79.1M
536Nov 2026MIT
Graphene
32.0M
8.2KNov 2024MIT
Strawberry
7.1M
4.7KNov 2026MIT
Ariadne
2.1M
2.3KOct 2026BSD-3-Clause
strawberry-graphql-django
2.0M
504Nov 2026MIT
Graphene SQLAlchemy
1.1M
986Jun 2020MIT
Graphene Django
1.1M
4.4KMar 2025MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

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

Downloads / mo
79.1M
Stars
536
Last release
3.3.2
License
MIT

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.

Limitations

  • 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.

Quickstart

From README.md
$ python -m pip install graphql-core
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))

graphql-core examples

From open-source projects on GitHub

Builds GraphQL API schemas using Python classes.

Downloads / mo
32.0M
Stars
8.2K
Last release
3.4.3
License
MIT

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.

Limitations

  • 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.

Quickstart

From README.md
$ pip install "graphene>=3.1"
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)

Graphene examples

From open-source projects on GitHub
def create_schema() -> graphene.Schema:
    return graphene.Schema(
        query=GrapheneQuery,
        mutation=GrapheneMutation,
        subscription=GrapheneSubscription,
        types=types(),
    )

Builds GraphQL schemas from Python dataclasses and type annotations.

Downloads / mo
7.1M
Stars
4.7K
Last release
0.341.2
License
MIT

Strengths

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

Limitations

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

Quickstart

From README.md
$ pip install "strawberry-graphql[cli]"
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)

Strawberry examples

From open-source projects on GitHub

Builds GraphQL servers around schemas written in SDL.

Downloads / mo
2.1M
Stars
2.3K
Last release
1.1.1
License
BSD-3-Clause

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.

Limitations

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

Quickstart

From README.md
$ pip install ariadne
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)

Ariadne examples

From open-source projects on GitHub

strawberry-graphql-django

Extends Strawberry GraphQL for Django.

Downloads / mo
2.0M
Stars
504
Last release
0.96.3
License
MIT

Quickstart

From README.md
$ pip install strawberry-graphql-django
# 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],
)

strawberry-graphql-django examples

From open-source projects on GitHub
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)

Graphene SQLAlchemy

Integrates Graphene with SQLAlchemy.

Downloads / mo
1.1M
Stars
986
Last release
2.3.0
License
MIT

Quickstart

From README.md
$ pip install "graphene-sqlalchemy>=2.0"
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)

Graphene SQLAlchemy examples

From open-source projects on GitHub

Graphene Django

Integrates Graphene with Django.

Downloads / mo
1.1M
Stars
4.4K
Last release
3.2.3
License
MIT

Quickstart

From README.md
$ pip install graphene-django
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)

Graphene Django examples

From open-source projects on GitHub

FAQ

Strawberry suits new APIs built from dataclasses and type annotations. Graphene suits code-first APIs with existing Django or SQLAlchemy integrations. Ariadne suits teams that write the schema first in SDL.

Define a schema with Strawberry types, Graphene classes, or an SDL string for Ariadne, then bind resolvers to its fields. Each framework serves the schema through an ASGI or WSGI integration.

Graphene Django generates Graphene types from Django models and serves them through a Django GraphQL view.

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.

For coding agents

Found your GraphQL library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official