Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phalt/gql_py
GraphQL Client for Pythonistas
https://github.com/phalt/gql_py
graphql http python
Last synced: about 1 month ago
JSON representation
GraphQL Client for Pythonistas
- Host: GitHub
- URL: https://github.com/phalt/gql_py
- Owner: phalt
- License: mit
- Created: 2018-07-26T13:38:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T18:50:30.000Z (over 4 years ago)
- Last Synced: 2024-09-28T21:42:30.815Z (about 2 months ago)
- Topics: graphql, http, python
- Language: Python
- Homepage: https://pypi.org/project/gql-py/
- Size: 34.2 KB
- Stars: 10
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
🌐🐍 gql_py
-------*GraphQL Client for Pythonistas*
gql_py is a Pythonic interface around graphQL APIs.
You've got a graphQL API, and you want to talk to it, right? For those of us who love HTTP standards, GraphQL's use of HTTP is questionable at best. The goal of this library is to remove the fuss of HTTP so you can deal with graphQL directly. Just how graphQL's developers intended.
.. image:: https://img.shields.io/pypi/v/gql_py.svg
:target: https://pypi.org/project/gql-py/.. image:: https://img.shields.io/pypi/pyversions/gql_py.svg
:target: https://pypi.org/project/gql-py/.. image:: https://img.shields.io/pypi/l/gql_py.svg
:target: https://pypi.org/project/gql-py/.. image:: https://img.shields.io/pypi/status/gql_py.svg
:target: https://pypi.org/project/gql-py/.. image:: https://circleci.com/gh/phalt/gql_py/tree/master.svg?style=svg
:target: https://circleci.com/gh/phalt/gql_py/tree/masterInstalling the project is easy:
.. code-block:: bash
pip install gql_py
Full blown example:
.. code-block:: python
from gql_py import Gql
gql = Gql(api='https://example.com/graphql')
query = '''
query ($bookId: ID!) {
book(id: $bookId) {
id
title
author
}
}
'''variables = {
'book_id': '654'
}response = qgl.send(query=query, variables=variables)
response.ok
>>> Trueresponse.errors
>>> Noneresponse.data
>>> {'book': {'id': '654', 'title': 'Ursula K. Le Guin', 'title': 'A Wizard of Earthsea'}}You can validate your graphql query string by passing the __validate__ flag in the __send__ method:
.. code-block:: python
gpl.send(query=query, validate=True)
>>> Traceback (most recent call last):
>>> graphql.error.syntax_error.GraphQLSyntaxError: Syntax Error: Expected Name, found }📖 Features
--------- No need to handle the HTTP layer. (You can still set HTTP headers, though!)
- Responses come back as named tuples - even errors!
- Validate your query strings easily.
- Python 3.6+✨ Future goals
---------------- Hydrate API responses into custom Python objects.
🏗 Status
----------gql.py is currently under development.
🎥 Credits
-----------This package was created with Cookiecutter_.
We use `Python Requests`_ for talking HTTP.
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`Python Requests`: https://github.com/audreyr/cookiecutter-pypackage