skillfed

graphene-pydantic

Graphene Pydantic integration

graphene-pydantic v0.6.1 501.9K downloads/30d#6,312 on PyPI249
Permissive license Apache-2.0 Active released

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-pydantic

uv

uv add graphene-pydantic

poetry

poetry add graphene-pydantic

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: Libraries

Tags

pydantic to graphqlgraphene pydantic integrationgraphql schema from pydantic modelspydantic graphql typesgraphql object type generatorpydantic model graphqlgraphene pydantic objecttype
graphql-integrationschema-generation

More Libraries packages