graphene-pydantic
Graphene Pydantic integration
What it is and what it does
graphene-pydantic is a bridge between Pydantic and Graphene that lets you define GraphQL schemas directly from your Pydantic models. Instead of writing separate GraphQL type definitions, you annotate your Pydantic model and wrap it in a PydanticObjectType or PydanticInputObjectType, and the package generates the corresponding GraphQL types automatically. This is useful when you already have Pydantic models for validation and want to expose them via GraphQL without duplicating type definitions.
The package supports both output types (for queries) and input types (for mutations), field exclusion, custom resolve functions, and forward declarations with circular references. It inherits from Graphene's ObjectType, so you can extend generated types with custom fields and resolvers. Known limitations include inability to handle GraphQL-incompatible Pydantic fields like mappings (dictionaries) and some caveats around union types and Python version compatibility.
Use it for:
- Build a GraphQL API from existing Pydantic models without redefining types in Graphene.
- Create GraphQL input types for mutations that accept Pydantic model data.
- Extend auto-generated GraphQL types with custom resolve functions for computed fields.
- Rapidly prototype GraphQL services where Pydantic validation and GraphQL schema are kept in sync.
- Handle forward declarations and circular model references in GraphQL schemas.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Converts Pydantic models into GraphQL object types and input types for use with Graphene, enabling you to build GraphQL APIs from your existing Pydantic validation schemas.
Yes. The package is actively maintained, has low install friction, carries a permissive license, and solves a real problem for teams already using Pydantic. It supports current Python versions (3.8–3.12) and has no known vulnerabilities. Install it if you're building GraphQL APIs on top of existing Pydantic models and want to avoid duplicating type definitions.
Install
graphene-pydantic on PyPI
pip
pip install graphene-pydanticuv
uv add graphene-pydanticpoetry
poetry add graphene-pydanticInstalling graphene-pydantic
Before you install
Low friction: pure Python wheel with only two runtime dependencies (graphene and pydantic). Actively maintained with recent commits; last release was in February 2024.
License in practice
Apache-2.0 is permissive; you can use this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install graphene-pydantic
import pydantic
from graphene_pydantic import PydanticObjectType
import graphene
class PersonModel(pydantic.BaseModel):
name: str
class Person(PydanticObjectType):
class Meta:
model = PersonModel
class Query(graphene.ObjectType):
people = graphene.List(Person)
schema = graphene.Schema(query=Query)
Verify before relying
- Whether the package handles all Pydantic field types (e.g., custom validators, computed fields) without manual workarounds.
- Performance characteristics when converting large or deeply nested Pydantic models to GraphQL schemas.
- Compatibility with recent versions of graphene and pydantic beyond the classifiers listed.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.8,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — graphene, pydantic |
| Maintenance | actively maintained — 925 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 501,910/month — #6,312 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: graphene_pydantic-0.6.1-py3-none-any.whl
Keywords: api, graphql, protocol, rest, relay, graphene, pydantic, model
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
graphene-sqlalchemyGraphene-SQLAlchemy exposes SQLAlchemy database…
permissive · top 15,000 on PyPI
grapheneGraphene is a Python library for building…
permissive · top 1,000 on PyPI
sparkdanticConverts Pydantic models to PySpark schemas…
unclear · top 5,000 on PyPI
graphene-djangoGraphene-Django bridges Django models and…
permissive · top 5,000 on PyPI
pydantic-to-pyarrowConverts pydantic model definitions to pyarrow…
permissive · top 15,000 on PyPI
graphql-queryBuilds GraphQL query strings programmatically…
permissive · top 15,000 on PyPI
datamodel-code-generatorGenerates Python data models (Pydantic,…
permissive · top 5,000 on PyPI
pydantic-factoriesGenerates mock data objects that conform to…
permissive · top 15,000 on PyPI
starlette-graphene3Mounts a GraphQL API built with Graphene v3…
permissive · top 15,000 on PyPI
graphene-file-uploadAdds file upload support to GraphQL mutations…
permissive · top 15,000 on PyPI