Metadata-Version: 2.1
Name: graphql-dataclass
Version: 1.0.6
Summary: A python library to generate dataclasses for GraphQL types
Home-page: https://github.com/nikikuzi/graphql-dataclass
Author: Mikita Kuzniatsou, Alex Dap
Author-email: Mikita Kuzniatsou <nikikuzi@gmail.com>, Alex Dap <shlisi2017@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Mikita Kuzniatsou
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/nikikuzi/graphql-dataclass/
Project-URL: Source Code, https://github.com/nikikuzi/graphql-dataclass/tree/1.0.6
Project-URL: Bug Tracker, https://github.com/nikikuzi/graphql-dataclass/issues
Project-URL: Release Notes, https://github.com/nikikuzi/graphql-dataclass/tree/1.0.6/RELEASE_NOTES.MD
Keywords: python,graphql,mapping,dataclass
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: anyio ==3.1.0
Requires-Dist: autoflake ==2.3.1
Requires-Dist: black ==24.8.0
Requires-Dist: isort ==5.13.2

# 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](https://github.com/nikikuzi/graphql-dataclass/blob/develop/codegen/README.MD)

The package using [autoflake](https://github.com/PyCQA/autoflake), [black](https://github.com/psf/black), [isort](https://github.com/pycqa/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'](https://github.com/nikikuzi/graphql-dataclass/blob/develop/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](https://github.com/konradhalas/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](https://github.com/nikikuzi/graphql-dataclass/blob/develop/tests/output/github), and [GeoDBCities API](https://github.com/nikikuzi/graphql-dataclass/blob/develop/tests/output/gdbc)

More command options are available [here](https://github.com/nikikuzi/graphql-dataclass/blob/develop/codegen/README.MD#usage-via-command-line)
