{ "info": { "author": "Baruc Almaguer", "author_email": "baruc@valiot.io", "bugtrack_url": null, "classifiers": [], "description": "# pygqlc\nPython client for graphql APIs\n\n### Scope\nThis is an open source project, please feel free to fork it and PR to contribute with the community!\nRepo for the project: https://github.com/valiot/pygqlc\n\n### Installation\nRequirements:\n- Python 3.6+\n- Pipenv\n\nInstall directly from pypi:\n\n```\n$ cd \n$ pipenv --python 3.7 # or 3.6\n$ pipenv shell\n$ pipenv install pygqlc\n$ python\n$ >> import pygqlc\n$ >> print(pygqlc.name)\n```\nIf you get \"pygqlc\" printed in the python repl, the installation succeded!\n\n### Usage\n```python\nimport os\nfrom pygqlc import GraphQLClient \ngql = GraphQLClient()\ngql.addEnvironment(\n 'dev',\n url=os.environ.get('API'), # should be an https url\n wss=os.environ.get('WSS'), # should be an ws/wss url\n headers={'Authorization': os.environ.get('TOKEN')},\n default=True)\n```\n#### From now on, you can access to the main API:\n`gql.query, gql.mutate, gql.subscribe`\n\nFor queries:\n```python\nquery = '''\nquery{\n authors{\n name\n }\n}\n'''\ndata, errors = gql.query( query )\n```\n\nFor mutations:\n```python\ncreate_author = '''\nmutation {\n createAuthor(){\n successful\n messages{field message}\n result{id insertedAt}\n }\n}\n'''\ndata, errors = gql.mutate( create_author )\n```\n\nFor subscriptions:\n\n```python\ndef on_auth_created(message):\n print(message)\n\nsub_author_created = '''\nsubscription{\n authorCreated{\n successful\n messages{field message}\n result{id insertedAt}\n }\n}\n'''\nunsub = gql.subscribe(sub_author_created, callback=on_auth_created)\n...\n# when finishing the subscription:\nunsub()\n# when finishing all subscriptions:\ngql.close()\n```\n\nThe subscribe method, returns an `unsubscribe` function,\nthis allows to stop subscriptions whenever needed.\n\nAfter finishing all subscriptions, the method\n`GraphQLClient.close()` should be called to close correctly the open GQL/websocket connections.\n\n### To be noted:\nAll main methods from the API accept a `variables` param.\nit is a dictionary type and may include variables from your queries or mutations:\n\n```python\nquery_with_vars = '''\nquery CommentsFromAuthor(\n $authorName: String!\n $limit: Int\n){\n author(\n findBy:{ name: $authorName }\n ){\n id\n name\n comments(\n orderBy:{desc: ID}\n limit: $limit\n ){\n id\n blogPost{name}\n body\n }\n }\n}\n'''\n\ndata, errors = gql.query(\n query=query_with_vars,\n variables={\n \"authorName\": \"Baruc\",\n \"limit\": 10\n }\n)\n```\n\nThere is also an optional parameter `flatten` that simplifies the response format:\n```python\n# From this:\nresponse = {\n 'data': {\n 'authors': [\n { 'name': 'Baruc' },\n { 'name': 'Juan' },\n { 'name': 'Gerardo' }\n ]\n }\n}\n# To this:\nauthors = [\n { 'name': 'Baruc' },\n { 'name': 'Juan' },\n { 'name': 'Gerardo' }\n]\n```\nSimplifying the data access from this:\n\n`response['data']['authors'][0]['name']`\n\nto this:\n\n`authors[0]['name']`\n\nIt is `query(query, variables, flatten=True)` by default, to avoid writing it down everytime\n\nThe `(_, errors)` part of the response, is the combination of GraphQL errors, and communication errors, simplifying validations, it has this form:\n```python\nerrors = [\n {\"field\": , \"message\":},\n {\"field\": , \"message\":},\n {\"field\": , \"message\":},\n ...\n]\n```\nThe field Attribute it's only available for GraphQL errors, when it is included in the response, so it's suggested that every mutation has at least this parameters in the response:\n```\nmutation{\n myMutation(){\n successful\n messages{\n field\n message\n }\n result{\n \n }\n }\n}\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/valiot/pygqlc", "keywords": "pygqlc", "license": "", "maintainer": "", "maintainer_email": "", "name": "pygqlc", "package_url": "https://pypi.org/project/pygqlc/", "platform": "", "project_url": "https://pypi.org/project/pygqlc/", "project_urls": { "Homepage": "https://github.com/valiot/pygqlc" }, "release_url": "https://pypi.org/project/pygqlc/1.1.1/", "requires_dist": [ "requests", "python-dotenv", "pydash", "websocket-client (==0.54.0)", "singleton-decorator", "tenacity" ], "requires_python": "", "summary": "GraphQL API Client for python language", "version": "1.1.1" }, "last_serial": 5810768, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "79e603b8963d5cc0a9bc70dcacc77d3c", "sha256": "4e80d37e078eac718003cdaa024fa68f8189e0584a63132079eb586f6c36a1fc" }, "downloads": -1, "filename": "pygqlc-0.1.0-py3.7.egg", "has_sig": false, "md5_digest": "79e603b8963d5cc0a9bc70dcacc77d3c", "packagetype": "bdist_egg", "python_version": "3.7", "requires_python": null, "size": 5658, "upload_time": "2019-09-01T02:47:29", "url": "https://files.pythonhosted.org/packages/83/4c/38642bea65bf0ee517de4debfe020fb0ff4ca73611871994806e961bf972/pygqlc-0.1.0-py3.7.egg" }, { "comment_text": "", "digests": { "md5": "f27ef845d12ac5027bc60bee0e211d80", "sha256": "3a6e8104889eb8ae8e54cdf674fe13ed4b6d9c38a34f1a4b0feddcddbfdec9d3" }, "downloads": -1, "filename": "pygqlc-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f27ef845d12ac5027bc60bee0e211d80", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6782, "upload_time": "2019-09-01T02:47:22", "url": "https://files.pythonhosted.org/packages/03/33/8c22006c2a99ac4043c62d459fd1b509c0a2f4ea2045709a84b06c7b336a/pygqlc-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "75641ada1283e40b1aef5432b0e96554", "sha256": "9bbb5c9482ff325af70aed7d4eec3d0aab42e6daf2f5a064c06c98f345d14b29" }, "downloads": -1, "filename": "pygqlc-0.1.0.tar.gz", "has_sig": false, "md5_digest": "75641ada1283e40b1aef5432b0e96554", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2967, "upload_time": "2019-09-01T02:47:30", "url": "https://files.pythonhosted.org/packages/0e/a2/d2557939a798db99a4d7f69412ccf75fbcb5a532b561a93ccb4e009d6d38/pygqlc-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "50fa4f6a69af757e4de18cb266393489", "sha256": "d02eafa69ce920d2e14c86f8c942b89cf12b9fa2e11907423fa17039ba925668" }, "downloads": -1, "filename": "pygqlc-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "50fa4f6a69af757e4de18cb266393489", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6913, "upload_time": "2019-09-01T02:47:24", "url": "https://files.pythonhosted.org/packages/92/ab/92dd99d2471d9bec7ca2b8f764ddd6568f85b25de1d7273d0a881d31a37b/pygqlc-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d8d36cf1e557157b4d769f809a2d5df0", "sha256": "70de45260dc374c37006200f5ce15f7f8cb031ce359cb7fe55c6d96f004efa20" }, "downloads": -1, "filename": "pygqlc-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d8d36cf1e557157b4d769f809a2d5df0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2998, "upload_time": "2019-09-01T02:47:31", "url": "https://files.pythonhosted.org/packages/4c/e5/a7d914ceecc2fe2745224d9b8f6ec43c23c8dd940b7b1bd9b50ed1a6b6f5/pygqlc-0.1.1.tar.gz" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "fc886a2f3b02941cb646fbffc80ed798", "sha256": "3978499fc47665c3f889542a39285f02d5fde9a7a8a6e81ad29165f660abc0ab" }, "downloads": -1, "filename": "pygqlc-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "fc886a2f3b02941cb646fbffc80ed798", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8379, "upload_time": "2019-09-01T21:25:20", "url": "https://files.pythonhosted.org/packages/0c/fc/f7cb6fce3cb0635acc199916906faf63bca37e42c45099955ab515a97ee8/pygqlc-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "193f8bced38950f73562c2fa19d915c5", "sha256": "1ca0caa3d619cccd362a41859ea6c4df49af6e417a3017cc08b9caa9b95f310e" }, "downloads": -1, "filename": "pygqlc-1.0.0.tar.gz", "has_sig": false, "md5_digest": "193f8bced38950f73562c2fa19d915c5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4418, "upload_time": "2019-09-01T21:25:25", "url": "https://files.pythonhosted.org/packages/61/b2/35e7f5268f4a555614023f4f13258d8d30af3fc6d972a707d1cca87daa04/pygqlc-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "d62d6aba1bec41f465dcc892a7fd8412", "sha256": "d4cabecdc97f50ac46fb56aa99c7ab8c1ae0f902ba3b5692264d00dc94afd6a0" }, "downloads": -1, "filename": "pygqlc-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d62d6aba1bec41f465dcc892a7fd8412", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8397, "upload_time": "2019-09-01T21:36:10", "url": "https://files.pythonhosted.org/packages/0d/6a/f1402203b309c7d6026d0a774618441913ed188dffca1c79f2041e6a9eed/pygqlc-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "19d82ea8861ea890581c2bd9be74fc37", "sha256": "e1086ffe32a0c7e11b33e15e277369989fae25b25b02544da3d537fda2c62aae" }, "downloads": -1, "filename": "pygqlc-1.0.1.tar.gz", "has_sig": false, "md5_digest": "19d82ea8861ea890581c2bd9be74fc37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4433, "upload_time": "2019-09-01T21:36:16", "url": "https://files.pythonhosted.org/packages/64/1c/bb8059c97c8935fa06965b3a488281a1f5455efcb9559f9dd25467f69fd8/pygqlc-1.0.1.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "d1d80d9c68c6c49a771e9fc21e583d9f", "sha256": "85e81575e53dd9e9db32bd9facb233fbbb3ec15282cecac0016a055929250d08" }, "downloads": -1, "filename": "pygqlc-1.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "d1d80d9c68c6c49a771e9fc21e583d9f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8448, "upload_time": "2019-09-03T00:34:53", "url": "https://files.pythonhosted.org/packages/f4/d8/eb0075fec50e5bc8e0b141ca4da604b47b3164d357823eadbb660cd24945/pygqlc-1.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "372bf460369b0ae418b6d9ea2c6d3d27", "sha256": "a94d4f6c0d025e40e323974cf9a4bfb232a70c4b7a50c409d28701f60d5d4c5d" }, "downloads": -1, "filename": "pygqlc-1.0.4.tar.gz", "has_sig": false, "md5_digest": "372bf460369b0ae418b6d9ea2c6d3d27", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5794, "upload_time": "2019-09-03T00:34:56", "url": "https://files.pythonhosted.org/packages/6a/87/78889cdab300e68c3b9dcab5af78fdb0326e7d62e9fda181a7bd9be34e50/pygqlc-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "4bc140a339bf41a50cd9556520e48bd5", "sha256": "e0267454e65e325deb0599af06b7fd129ce5f9177d1b2aa95a5cecc30e0ef54e" }, "downloads": -1, "filename": "pygqlc-1.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "4bc140a339bf41a50cd9556520e48bd5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8527, "upload_time": "2019-09-03T00:34:55", "url": "https://files.pythonhosted.org/packages/28/db/70ba67e921725cde2fe99bb362f9af3bcbf8622283f9c8e6c6c2f90c9a52/pygqlc-1.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "81dd478ed5ffd971dccd3476a3f7ddac", "sha256": "06a782bf9740ba458c07a1051373d4e7fe4ac4a33d7f22c2aa3a8c2b3682ac3a" }, "downloads": -1, "filename": "pygqlc-1.0.5.tar.gz", "has_sig": false, "md5_digest": "81dd478ed5ffd971dccd3476a3f7ddac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5799, "upload_time": "2019-09-03T00:34:58", "url": "https://files.pythonhosted.org/packages/b3/cf/1499dcc36c8a63e8beb2dfd745187ebb44a3ce1ad3bddf7f6604c3484e03/pygqlc-1.0.5.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "42bece3e23d82fa40bcb904da4d70100", "sha256": "a192849505db565d2407eda4fbcd9e03905eae7afec5a9992c5b126ea03b545f" }, "downloads": -1, "filename": "pygqlc-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "42bece3e23d82fa40bcb904da4d70100", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7500, "upload_time": "2019-09-03T00:48:58", "url": "https://files.pythonhosted.org/packages/2d/e1/940d558cd82feb3c33a0ccd839760a3402681d515f649749a7a86a7d9211/pygqlc-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "60fbc737cdec6947f174efb29e0fdfb3", "sha256": "f8cb550042b0fde53d7ef9c8f91321887e0e64d824d0a23e3ca6ee107ec64904" }, "downloads": -1, "filename": "pygqlc-1.0.8.tar.gz", "has_sig": false, "md5_digest": "60fbc737cdec6947f174efb29e0fdfb3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6409, "upload_time": "2019-09-03T00:49:00", "url": "https://files.pythonhosted.org/packages/9b/fe/1e3a0b0d4c2bc8055916dcf9d0ee683cb22d1ffdbf1c59f3750ef539f29d/pygqlc-1.0.8.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "54ea15bc2fc8f1c71aa5f9d9133ed16e", "sha256": "7ae021733a1194cc2a85a9ef6e7156306ca5edb8c4a45df3b2be98e319cd832a" }, "downloads": -1, "filename": "pygqlc-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "54ea15bc2fc8f1c71aa5f9d9133ed16e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10451, "upload_time": "2019-09-09T18:26:31", "url": "https://files.pythonhosted.org/packages/a6/9d/3a0c760410ef9268e7f4158304f013ddd8fc29c2b4bfcc93446eb594d241/pygqlc-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4209e03ef4717d4dae5de1f7a0c229f3", "sha256": "4340e4fcaa4fa4a7f4df97e3f32bd37a473d893be47a7e36d0c4e91f44347b50" }, "downloads": -1, "filename": "pygqlc-1.1.0.tar.gz", "has_sig": false, "md5_digest": "4209e03ef4717d4dae5de1f7a0c229f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8819, "upload_time": "2019-09-09T18:26:33", "url": "https://files.pythonhosted.org/packages/06/02/b039a670b9933221ffb3ea6594493a37cdfba7b26ea35612af344f9bbc53/pygqlc-1.1.0.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "ee9e71806aed666a0199dd56c0c84a04", "sha256": "cb8c71e981af8c14b43c319cb0ef2a09f0aac6dc9ea9e75ed8f1b2577fef81be" }, "downloads": -1, "filename": "pygqlc-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ee9e71806aed666a0199dd56c0c84a04", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10527, "upload_time": "2019-09-10T19:14:28", "url": "https://files.pythonhosted.org/packages/33/3c/0505612519f62e05ae686b768b5c475b495a6de3243965b105ba0d34620c/pygqlc-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a6c8ed4865429f9e8e2f0870a2f2b379", "sha256": "dd7d11256a1e247f2b3c3ef59868f2c2358af42310818edd7dfab17b03d545bc" }, "downloads": -1, "filename": "pygqlc-1.1.1.tar.gz", "has_sig": false, "md5_digest": "a6c8ed4865429f9e8e2f0870a2f2b379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8897, "upload_time": "2019-09-10T19:14:29", "url": "https://files.pythonhosted.org/packages/f3/62/b3426ba5d13e938dd92ba786fa308963da73098f8ca51e3787cf291d3bc5/pygqlc-1.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ee9e71806aed666a0199dd56c0c84a04", "sha256": "cb8c71e981af8c14b43c319cb0ef2a09f0aac6dc9ea9e75ed8f1b2577fef81be" }, "downloads": -1, "filename": "pygqlc-1.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "ee9e71806aed666a0199dd56c0c84a04", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10527, "upload_time": "2019-09-10T19:14:28", "url": "https://files.pythonhosted.org/packages/33/3c/0505612519f62e05ae686b768b5c475b495a6de3243965b105ba0d34620c/pygqlc-1.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a6c8ed4865429f9e8e2f0870a2f2b379", "sha256": "dd7d11256a1e247f2b3c3ef59868f2c2358af42310818edd7dfab17b03d545bc" }, "downloads": -1, "filename": "pygqlc-1.1.1.tar.gz", "has_sig": false, "md5_digest": "a6c8ed4865429f9e8e2f0870a2f2b379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8897, "upload_time": "2019-09-10T19:14:29", "url": "https://files.pythonhosted.org/packages/f3/62/b3426ba5d13e938dd92ba786fa308963da73098f8ca51e3787cf291d3bc5/pygqlc-1.1.1.tar.gz" } ] }