Skip to main content

A python library to generate dataclasses for GraphQL types

Project description

graphql-dataclass

A python library to generate dataclasses for graphql schema.

Introduction

This library generates dataclasses which corresponding python code convention. Library is not working as client for graphql, only dataclasses mappers for GraphQL types

This document contains a quick overview of the functionalities, for more details and options you can read here:

The package using autoflake, black, isort libraries for generateed code formatting and also python 3 (3.10+) standard libraries.

Usage in a nutshell

Installation

Available in PyPI, the following command will install the library:

pip install graphql-dataclass

Generate python code from schema

To generate the code execute the following command:

gqldataclass generate ./pathToOutputFolder -apiArgs ./<pathToArgsFile>/generatorArgs.json

This command requires a json file containing the parameters needed to get the GraphQL schema

A sample is available in the main folder 'cli_args.json'.

The following python files will be generated:

  • scalars.py -> GraphQL scalar types as python type aliases
  • enums.py -> GraphQL enum types as Enum classes
  • gql_types.py -> GraphQL object types as classes
  • gql_simple_types.py -> GraphQL object types as classes not using other object types
  • unions.py -> GraphQL Unions as python Unions
  • gql_forward_reference.py -> file with types forward references, dacite-compatible
  • ${class_name}.py -> GraphQL object types as classes, which affected by circular dependencies

These links show code generated using the library Github GraphQL API, and GeoDBCities API

More command options are available here

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

graphql_dataclass-1.0.5.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

graphql_dataclass-1.0.5-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file graphql_dataclass-1.0.5.tar.gz.

File metadata

  • Download URL: graphql_dataclass-1.0.5.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for graphql_dataclass-1.0.5.tar.gz
Algorithm Hash digest
SHA256 6e0d88e345ffa310fa053bfb07885ce4f95bf82d121c2bdd5c5a9e53d4f0babd
MD5 bd7c042e5e53075f4dfa6964f909b1c1
BLAKE2b-256 c64777ff28ba103908f6ade2c4458ece89d395de3e605df54a86acae73a0d46a

See more details on using hashes here.

File details

Details for the file graphql_dataclass-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for graphql_dataclass-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 e288cd37f8c3f5ae67035399a717fa09a8992e2b21de99bf5a4d4fb6f2a722a4
MD5 5b8dfdb4f39c276b37148a43b2074eb8
BLAKE2b-256 281b4dc46fde889b6441586e9c055c51b0deba9c23511ba153ac64b3c9683f7a

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