Cloud Parts

Graphene

The oldest Python GraphQL library: code first, with its own field classes such as graphene.String and a resolve_ method per field.

What it is
API frameworks (graphql libraries)
Type
Open source
Made by
GraphQL-Python community (created by Syrus Akbary)
License
MIT
Facts checked
9 October 2026

What it is

Graphene is code first, but not built on type hints. You subclass graphene.ObjectType and declare each field as a class attribute holding a Graphene type: title = graphene.String(required=True) becomes title: String!, and book = graphene.Field(Book) points at another type. Arguments are declared the same way, and their snake_case names become camelCase in the schema, so first_name turns into firstName. Each field can have a resolver method named resolve_<field>, which gets the parent value, an info object and the arguments. graphene.Schema(query=Query) builds a GraphQL-core schema, and schema.execute() runs a query against it. Relay support (nodes, connections and mutations) is built in, and separate packages connect it to Django, SQLAlchemy and MongoDB models and to Apollo Federation.

Graphene 3 (November 2021) moved onto GraphQL-core 3, added subscriptions and dropped Python 2. Since then development has slowed: the latest release is 3.4.3 from November 2024, also the latest commit, and its README asks for contributors. It requires graphql-core older than 3.3, so it stays on the 3.2 line that follows GraphQL.js 16. Graphene itself has no web server. Starlette once shipped a GraphQLApp for it but deprecated it, and the FastAPI docs point to the third-party starlette-graphene3 package, whose repository was last updated in September 2023, while recommending Strawberry for new projects.

Why teams pick it

  • Mature, with a large ecosystem: graphene-django, graphene-sqlalchemy, graphene-mongo and graphene-federation build types from existing models
  • Built-in Relay support: nodes with global IDs, cursor connections and Relay-style mutations
  • Code first: no SDL file to keep in sync, and snake_case Python maps to camelCase GraphQL automatically
  • Spec-compliant schemas that work with any GraphQL client, such as Relay, Apollo and gql

Watch out for

  • Little recent development: no release or commit since November 2024
  • Pinned to graphql-core below 3.3, so it can’t use GraphQL.js 17 features such as @defer and @stream
  • Field types are Graphene objects, not Python type hints, so the schema and your type annotations are written separately
  • No ASGI server of its own: FastAPI and Starlette need the third-party starlette-graphene3, itself untouched since 2023

More of the GraphQL-core family

What all graphql libraries have in common →

How it fits with other technologies

The same book query, code first with Graphene’s own type classes · python

# pip install graphene   (3.4.3; installs graphql-core 3.2.x)
import graphene


class Book(graphene.ObjectType):
    title = graphene.String(required=True)
    author = graphene.String(required=True)


class Query(graphene.ObjectType):
    book = graphene.Field(Book)

    def resolve_book(root, info):
        return Book(title="Dune", author="Frank Herbert")


schema = graphene.Schema(query=Query)

print(schema)
# type Query {
#   book: Book
# }
#
# type Book {
#   title: String!
#   author: String!
# }

result = schema.execute("{ book { title author } }")
print(result.data)  # {'book': {'title': 'Dune', 'author': 'Frank Herbert'}}

# Serve it from FastAPI (pip install starlette-graphene3):
# from fastapi import FastAPI
# from starlette_graphene3 import GraphQLApp
# app = FastAPI()
# app.mount("/graphql", GraphQLApp(schema))

See it in a real stack

No architecture uses Graphene yet. Drop it into the playground and wire it up yourself.Open playground →
Where it came from2015–2024

Facebook published the GraphQL spec in July 2015. In October 2015 Syrus Akbary released Graphene, together with graphql-core, Akbary’s Python port of GraphQL.js. By December 2015 it had Django support, and SQLAlchemy followed in January 2016. For about three years it was Python’s only real GraphQL library. Graphene 1.0 (September 2016) was announced as production ready, and Graphene 2.0 (October 2017) simplified how types are implemented.

Akbary later handed maintenance to members of the GraphQL-Python community. Graphene 3.0, in November 2021, rebuilt it on GraphQL-core 3, the modern port of GraphQL.js, added subscriptions and better enums, and dropped Python 2. By then Strawberry and Ariadne had arrived, and FastAPI’s docs now recommend Strawberry. Releases continued until 3.4.3 in November 2024.

Why it’s built this way

Code first, with its own type classes
Instead of writing SDL, you describe the schema in Python. In 2015 type hints had only just arrived (Python 3.5) and dataclasses only arrived later, in Python 3.7, so fields are Graphene objects that carry their GraphQL type, arguments and options.
Relay built in
Relay, Facebook’s GraphQL client, has its own specifications for global object identification and cursor connections. Graphene provides nodes, connections and mutations that follow them, so a Python API works with Relay directly.
Data agnostic, with integrations as add-ons
Graphene works with any data source, from Django and SQLAlchemy models to plain Python objects. Model integrations live in separate packages, such as graphene-django and graphene-sqlalchemy.

Timeline

  1. 2015

    First release by Syrus Akbary in October

  2. 2016

    SQLAlchemy support in January; 1.0 in September

  3. 2017

    Graphene 2.0 in October

  4. 2021

    Graphene 3.0 on GraphQL-core 3 in November

  5. 2024

    3.4.3 in November, the latest release

Sources9 · facts checked 9 October 2026

Improve this page on GitHub