gql


Namegql JSON
Version 3.5.0 PyPI version JSON
download
home_pagehttps://github.com/graphql-python/gql
SummaryGraphQL client for Python
upload_time2024-01-03 14:40:38
maintainer
docs_urlNone
authorSyrus Akbary
requires_python
licenseMIT
keywords api graphql protocol rest relay gql client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # GQL

This is a GraphQL client for Python 3.7+.
Plays nicely with `graphene`, `graphql-core`, `graphql-js` and any other GraphQL implementation compatible with the spec.

GQL architecture is inspired by `React-Relay` and `Apollo-Client`.

[![GitHub-Actions][gh-image]][gh-url]
[![pyversion][pyversion-image]][pyversion-url]
[![pypi][pypi-image]][pypi-url]
[![Anaconda-Server Badge][conda-image]][conda-url]
[![codecov][codecov-image]][codecov-url]

[gh-image]: https://github.com/graphql-python/gql/workflows/Tests/badge.svg
[gh-url]: https://github.com/graphql-python/gql/actions?query=workflow%3ATests
[pyversion-image]: https://img.shields.io/pypi/pyversions/gql
[pyversion-url]: https://pypi.org/project/gql/
[pypi-image]: https://img.shields.io/pypi/v/gql.svg?style=flat
[pypi-url]: https://pypi.org/project/gql/
[conda-image]: https://img.shields.io/conda/vn/conda-forge/gql.svg
[conda-url]: https://anaconda.org/conda-forge/gql
[codecov-image]: https://codecov.io/gh/graphql-python/gql/branch/master/graph/badge.svg
[codecov-url]: https://codecov.io/gh/graphql-python/gql

## Documentation

The complete documentation for GQL can be found at
[gql.readthedocs.io](https://gql.readthedocs.io).

## Features

* Execute GraphQL queries using [different protocols](https://gql.readthedocs.io/en/latest/transports/index.html):
  * http
  * websockets:
    * apollo or graphql-ws protocol
    * Phoenix channels
    * AWS AppSync realtime protocol (experimental)
* Possibility to [validate the queries locally](https://gql.readthedocs.io/en/latest/usage/validation.html) using a GraphQL schema provided locally or fetched from the backend using an instrospection query
* Supports GraphQL queries, mutations and [subscriptions](https://gql.readthedocs.io/en/latest/usage/subscriptions.html)
* Supports [sync or async usage](https://gql.readthedocs.io/en/latest/async/index.html), [allowing concurrent requests](https://gql.readthedocs.io/en/latest/advanced/async_advanced_usage.html#async-advanced-usage)
* Supports [File uploads](https://gql.readthedocs.io/en/latest/usage/file_upload.html)
* Supports [Custom scalars / Enums](https://gql.readthedocs.io/en/latest/usage/custom_scalars_and_enums.html)
* [gql-cli script](https://gql.readthedocs.io/en/latest/gql-cli/intro.html) to execute GraphQL queries or download schemas from the command line
* [DSL module](https://gql.readthedocs.io/en/latest/advanced/dsl_module.html) to compose GraphQL queries dynamically

## Installation

You can install GQL with all the optional dependencies using pip:

```bash
# Quotes may be required on certain shells such as zsh.
pip install "gql[all]"
```

> **NOTE**: See also [the documentation](https://gql.readthedocs.io/en/latest/intro.html#less-dependencies) to install GQL with less extra dependencies depending on the transports you would like to use or for alternative installation methods.

## Usage

### Basic usage

```python
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# Select your transport with a defined url endpoint
transport = AIOHTTPTransport(url="https://countries.trevorblades.com/")

# Create a GraphQL client using the defined transport
client = Client(transport=transport, fetch_schema_from_transport=True)

# Provide a GraphQL query
query = gql(
    """
    query getContinents {
      continents {
        code
        name
      }
    }
"""
)

# Execute the query on the transport
result = client.execute(query)
print(result)
```

Executing the above code should output the following result:

```
$ python basic_example.py
{'continents': [{'code': 'AF', 'name': 'Africa'}, {'code': 'AN', 'name': 'Antarctica'}, {'code': 'AS', 'name': 'Asia'}, {'code': 'EU', 'name': 'Europe'}, {'code': 'NA', 'name': 'North America'}, {'code': 'OC', 'name': 'Oceania'}, {'code': 'SA', 'name': 'South America'}]}
```

> **WARNING**: Please note that this basic example won't work if you have an asyncio event loop running. In some
> python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you. In that case you
> should use instead the [async usage example](https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage).

## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)

## License

[MIT License](https://github.com/graphql-python/gql/blob/master/LICENSE)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/graphql-python/gql",
    "name": "gql",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "api graphql protocol rest relay gql client",
    "author": "Syrus Akbary",
    "author_email": "me@syrusakbary.com",
    "download_url": "https://files.pythonhosted.org/packages/3d/85/feda24b33adcc6c8463a62a8e2ca2cc3425dc6d687388ff728ceae231204/gql-3.5.0.tar.gz",
    "platform": "any",
    "description": "# GQL\n\nThis is a GraphQL client for Python 3.7+.\nPlays nicely with `graphene`, `graphql-core`, `graphql-js` and any other GraphQL implementation compatible with the spec.\n\nGQL architecture is inspired by `React-Relay` and `Apollo-Client`.\n\n[![GitHub-Actions][gh-image]][gh-url]\n[![pyversion][pyversion-image]][pyversion-url]\n[![pypi][pypi-image]][pypi-url]\n[![Anaconda-Server Badge][conda-image]][conda-url]\n[![codecov][codecov-image]][codecov-url]\n\n[gh-image]: https://github.com/graphql-python/gql/workflows/Tests/badge.svg\n[gh-url]: https://github.com/graphql-python/gql/actions?query=workflow%3ATests\n[pyversion-image]: https://img.shields.io/pypi/pyversions/gql\n[pyversion-url]: https://pypi.org/project/gql/\n[pypi-image]: https://img.shields.io/pypi/v/gql.svg?style=flat\n[pypi-url]: https://pypi.org/project/gql/\n[conda-image]: https://img.shields.io/conda/vn/conda-forge/gql.svg\n[conda-url]: https://anaconda.org/conda-forge/gql\n[codecov-image]: https://codecov.io/gh/graphql-python/gql/branch/master/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/graphql-python/gql\n\n## Documentation\n\nThe complete documentation for GQL can be found at\n[gql.readthedocs.io](https://gql.readthedocs.io).\n\n## Features\n\n* Execute GraphQL queries using [different protocols](https://gql.readthedocs.io/en/latest/transports/index.html):\n  * http\n  * websockets:\n    * apollo or graphql-ws protocol\n    * Phoenix channels\n    * AWS AppSync realtime protocol (experimental)\n* Possibility to [validate the queries locally](https://gql.readthedocs.io/en/latest/usage/validation.html) using a GraphQL schema provided locally or fetched from the backend using an instrospection query\n* Supports GraphQL queries, mutations and [subscriptions](https://gql.readthedocs.io/en/latest/usage/subscriptions.html)\n* Supports [sync or async usage](https://gql.readthedocs.io/en/latest/async/index.html), [allowing concurrent requests](https://gql.readthedocs.io/en/latest/advanced/async_advanced_usage.html#async-advanced-usage)\n* Supports [File uploads](https://gql.readthedocs.io/en/latest/usage/file_upload.html)\n* Supports [Custom scalars / Enums](https://gql.readthedocs.io/en/latest/usage/custom_scalars_and_enums.html)\n* [gql-cli script](https://gql.readthedocs.io/en/latest/gql-cli/intro.html) to execute GraphQL queries or download schemas from the command line\n* [DSL module](https://gql.readthedocs.io/en/latest/advanced/dsl_module.html) to compose GraphQL queries dynamically\n\n## Installation\n\nYou can install GQL with all the optional dependencies using pip:\n\n```bash\n# Quotes may be required on certain shells such as zsh.\npip install \"gql[all]\"\n```\n\n> **NOTE**: See also [the documentation](https://gql.readthedocs.io/en/latest/intro.html#less-dependencies) to install GQL with less extra dependencies depending on the transports you would like to use or for alternative installation methods.\n\n## Usage\n\n### Basic usage\n\n```python\nfrom gql import gql, Client\nfrom gql.transport.aiohttp import AIOHTTPTransport\n\n# Select your transport with a defined url endpoint\ntransport = AIOHTTPTransport(url=\"https://countries.trevorblades.com/\")\n\n# Create a GraphQL client using the defined transport\nclient = Client(transport=transport, fetch_schema_from_transport=True)\n\n# Provide a GraphQL query\nquery = gql(\n    \"\"\"\n    query getContinents {\n      continents {\n        code\n        name\n      }\n    }\n\"\"\"\n)\n\n# Execute the query on the transport\nresult = client.execute(query)\nprint(result)\n```\n\nExecuting the above code should output the following result:\n\n```\n$ python basic_example.py\n{'continents': [{'code': 'AF', 'name': 'Africa'}, {'code': 'AN', 'name': 'Antarctica'}, {'code': 'AS', 'name': 'Asia'}, {'code': 'EU', 'name': 'Europe'}, {'code': 'NA', 'name': 'North America'}, {'code': 'OC', 'name': 'Oceania'}, {'code': 'SA', 'name': 'South America'}]}\n```\n\n> **WARNING**: Please note that this basic example won't work if you have an asyncio event loop running. In some\n> python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you. In that case you\n> should use instead the [async usage example](https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage).\n\n## Contributing\nSee [CONTRIBUTING.md](CONTRIBUTING.md)\n\n## License\n\n[MIT License](https://github.com/graphql-python/gql/blob/master/LICENSE)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "GraphQL client for Python",
    "version": "3.5.0",
    "project_urls": {
        "Homepage": "https://github.com/graphql-python/gql"
    },
    "split_keywords": [
        "api",
        "graphql",
        "protocol",
        "rest",
        "relay",
        "gql",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74fb01a200e1c31b79690427c8e983014e4220d2652b4372a46fe4598e1d7a8e",
                "md5": "1a56b1e7697fb9f24b4630f7540c973e",
                "sha256": "70dda5694a5b194a8441f077aa5fb70cc94e4ec08016117523f013680901ecb7"
            },
            "downloads": -1,
            "filename": "gql-3.5.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1a56b1e7697fb9f24b4630f7540c973e",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 74001,
            "upload_time": "2024-01-03T14:40:36",
            "upload_time_iso_8601": "2024-01-03T14:40:36.767699Z",
            "url": "https://files.pythonhosted.org/packages/74/fb/01a200e1c31b79690427c8e983014e4220d2652b4372a46fe4598e1d7a8e/gql-3.5.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d85feda24b33adcc6c8463a62a8e2ca2cc3425dc6d687388ff728ceae231204",
                "md5": "5bc49c18e3f8129d5c81356380c3549c",
                "sha256": "ccb9c5db543682b28f577069950488218ed65d4ac70bb03b6929aaadaf636de9"
            },
            "downloads": -1,
            "filename": "gql-3.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5bc49c18e3f8129d5c81356380c3549c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 179939,
            "upload_time": "2024-01-03T14:40:38",
            "upload_time_iso_8601": "2024-01-03T14:40:38.964591Z",
            "url": "https://files.pythonhosted.org/packages/3d/85/feda24b33adcc6c8463a62a8e2ca2cc3425dc6d687388ff728ceae231204/gql-3.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-03 14:40:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "graphql-python",
    "github_project": "gql",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "gql"
}
        
Elapsed time: 0.20138s