Skip to main content

Easy way to convert pydantic2graphene models to graphene objects.

Project description

pydantic2graphene

CI Forwards Compatibility Coverage pypi versions license

Easy way to convert pydantic2graphene models to graphene objects.

Install

$ pip install pydantic2graphene

A Simple Example

Using to_graphene

import pydantic
import pydantic2graphene

class User(pydantic.BaseModel):
    email: str
    active: bool = False

UserGql = pydantic2graphene.to_graphene(User)

Converting to multiple graphene types with ConverterToGrapheneBase

import pydantic
import pydantic2graphene

class User(pydantic.BaseModel):
    email: str
    active: bool = False

class UserConverter(pydantic2graphene.ConverterToGrapheneBase):
    class Config:
        model = User

UserGql = UserConverter.as_class()  # graphene.ObjectType
UserInputGql = UserConverter.as_class(graphene.InputObjectType)
UserInterfaceGql = UserConverter.as_class(graphene.Interface)

More Examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic2graphene-0.5.1.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file pydantic2graphene-0.5.1.tar.gz.

File metadata

  • Download URL: pydantic2graphene-0.5.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.8.2 requests/2.27.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for pydantic2graphene-0.5.1.tar.gz
Algorithm Hash digest
SHA256 833c7f9bbd26f692e0294ee580ba3048005cbe2c3d59eaeb17b82d4d6b233b10
MD5 6d168cddf10cefbd0801d0b09e6b831a
BLAKE2b-256 6130fc601ca242c0946662ceb13f44a0b1cb4fc9731e5e5fb23541d15f6a8edf

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page