Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
graphql2python is a tool that generates python code out of your GraphQL schema. If you are using python as GraphQL client you can to generate pydantic data-model with graphql2python. The documentation for graphql2python can be found at https://denisart.github.io/graphql2python.
GraphQL query generation moved to https://github.com/denisart/graphql-query
The special example for gql users here.
Install with pip
pip install graphql2python
Create the following file
# graphql2python.yaml
schema: ./schema.graphql
output: ./model.py
and run the following command
graphql2python render --config ./graphql2python.yaml
Global keywords
keyword | description |
---|---|
schema | A path to the target GraphQL schema file. |
output | A file name for output py file. |
license_file | An optional path to a file with license for output py file. |
options | Optional options for render of output py file. |
Options keywords
keywords | description |
---|---|
max_line_len | The maximum of line length of output py file. Default is 120 . |
name_suffix | A suffix for invalid field name (as python object name). Default is "_" . |
each_field_optional | Each fields of interfaces and objects are optional. Default is false . |
add_from_dict | Add from_dict (dict -> model) method to the general class. Default is false . |
add_to_dict | Add to_dict (model -> dict) method to the general class. Default is false . |
scalar_pytypes | A dict with python types for custom GraphQL scalars. Maps from scalar name to python type name. Default is empty dict. |
fields_setting | Settings for interfaces or objects fields. Maps from object name to a dict with setting. Default is empty dict. |
fields_setting
keywords for some object name
keywords | desciption |
---|---|
alias | An alias for a field (see Field.alias for pydantic). Default is null. |
new_name | A new name for a field. Default is null. |
An example for graphql2python.yaml
config:
# graphql2python.yaml
schema: ./schema/schema.graphql
output: ./model/model.py
license_file: ./LICENSE
options:
scalar_pytypes:
String: str
Float: float
Int: int
ID: str
Boolean: bool
DateTime: datetime
Date: date
max_line_len: 79
each_field_optional: true
fields_setting:
MyObjectName:
from:
alias: from
new_name: correct_from
FAQs
Tools for GraphQL client in python.
We found that graphql2python demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.