Skip to main content

Python package that converts GraphQL query into dictionary.

Project description

gql-query-utils

Python package with graphql queries utilities.

Install

Install with pip:

pip install gql-query-utils

Utilities

Convert graphql query string into dictionary

from gql_query_utils.utils import query_to_dict 

query_dict = query_to_dict("""
query GetThisStuff {
    viewer {
        personal(criteria: {
            name: "PETER",
            lastName: "SCHMIDT"
        }) {
            name
            address
        }
    }
}""")

print(query_dict)

Output:

{
  "query": {
    "viewer": {
      "personal": {
        "__args": {
          "criteria": {
            "name": "PETER",
            "lastName": "SCHMIDT"
          }
        },
        "name": true,
        "address": true
      }
    }
  }
}

Usage

from gql_query_utils.utils import query_to_dict 

query_to_dict(""" ${GQL_QUERY} """)

License

MIT

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

gql_query_utils-1.0.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

gql_query_utils-1.0.1-py3-none-any.whl (3.4 kB view hashes)

Uploaded Python 3

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