--- id: graphene-pydantic version: "0.6.1" license: Apache-2.0 license_treatment: permissive maintenance: active --- # graphene-pydantic — Graphene Pydantic integration License: permissive · Maintenance: active · Downloads: 501.9K/mo ## 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 above — 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 pip install graphene-pydantic uv add graphene-pydantic 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_current - Install friction: low - Maintenance: active - Downloads: 501.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pydantic to graphql, graphene pydantic integration, graphql schema from pydantic models, pydantic graphql types, graphql object type generator, pydantic model graphql, graphene pydantic objecttype, graphql-integration, schema-generation [View on SkillFed](https://skillfed.io/packages/graphene-pydantic) · [View on PyPI](https://pypi.org/project/graphene-pydantic/)