Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-dataclass

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-dataclass

A python library to generate dataclasses for GraphQL types

  • 1.0.6
  • PyPI
  • Socket score

Maintainers
1

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:

  • Code Generation

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

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc