{ "info": { "author": "Devin Fee", "author_email": "devin@devinfee.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "===================\n``graphql-ws-next``\n===================\n\nA GraphQL WebSocket server and client to facilitate GraphQL queries, mutations and subscriptions over WebSocket (for Python 3.6+).\nThis code is based on the current implementation of `subscriptions-transport-ws `_.\n\n\nGetting Started\n===============\n\nStart by installing the package using pip:\n\n.. code: shell\n\n pip install graphql-ws-next\n\nOr, by using your favorite package manager, like `Poetry `_:\n\n.. code: shell\n\n poetry add graphql-ws-next\n\n\nWith ``aiohttp``\n================\n\nUsage with ``aiohttp`` is simple:\n\n.. code: python\n\n import aiohttp.web\n import graphql_ws\n from graphql_ws.aiohttp import AiohttpConnectionContext\n\n async def handle_subscriptions(\n request: aiohttp.web.Request\n ) -> aiohttp.web.WebSocketResponse:\n wsr = aiohttp.web.WebSocketResponse(protocols=(graphql_ws.WS_PROTOCOL,))\n request.app[\"websockets\"].add(wsr)\n await wsr.prepare(request)\n await request.app[\"subscription_server\"].handle(wsr, None)\n request.app[\"websockets\"].remove(wsr)\n return wsr\n\n def make_app(schema: graphql.GraphQLSchema) -> aiohttp.web.Application:\n app = aiohttp.web.Application()\n app.router.add_get(\"/subscriptions\", handle_subscriptions)\n\n app[\"subscription_server\"] = graphql_ws.SubscriptionServer(\n schema, AiohttpConnectionContext\n )\n app[\"websockets\"] = set()\n\n async def on_shutdown(app):\n await asyncio.wait([wsr.close() for wsr in app[\"websockets\"]])\n\n app.on_shutdown.append(on_shutdown)\n return app\n\n if __name__ == '__main__':\n app = make_app(schema) # you supply your GraphQLSchema\n aiohttp.web.run_app()\n\n\nFor other frameworks\n====================\n\nAdding support for other web frameworks is simple.\nA framework must provide a concrete implementation of ``graphql_ws.abc.AbstractConnectionContext``, and then it's ready to use with the ``SubscriptionServer``.\n\nUsage\n=====\n\nUsing `apollo-link-ws `_ you can opt to use websockets for queries and mutations in addition to subscriptions.\n\nUse it with GraphiQL\n====================\n\nLook in the `demo<./demo>_` directory to see usage examples for GraphiQL.\nDue to the implementation of the javascript client for GraphiQL (`GraphiQL-Subscriptions-Fetcher `_), queries and mutations will not be handled over websocket.\n\nContributing\n============\n\nThis project uses `Poetry `_, so to contribute, simply fork and clone this repository, and then set up your virtual environment using:\n\n.. code: shell:\n\n cd graphql-ws-next\n poetry develop .\n\nIf you don't yet have Poetry installed, please follow the `documentation for installation `_.\n\nCode formatting is done via `black `_, and code should be well-typed using `mypy `_.\n\n\nLicense\n=======\nThis package is licensed under the MIT License.\n", "description_content_type": "text/x-rst", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/dfee/graphql-ws-next", "keywords": "graphql,subscriptions,graphene,websockets", "license": "", "maintainer": "Devin Fee", "maintainer_email": "devin@devinfee.com", "name": "graphql-ws-next", "package_url": "https://pypi.org/project/graphql-ws-next/", "platform": "", "project_url": "https://pypi.org/project/graphql-ws-next/", "project_urls": { "Homepage": "https://github.com/dfee/graphql-ws-next" }, "release_url": "https://pypi.org/project/graphql-ws-next/1.0.0/", "requires_dist": [ "aiohttp (>=3.4,<4.0)", "graphql-core-next (>=1.0,<2.0)" ], "requires_python": ">=3.6,<4.0", "summary": "Websocket server for GraphQL subscriptions", "version": "1.0.0" }, "last_serial": 4294618, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "e66c40dab5feccac94787dc689635ca0", "sha256": "d76a019ea64730af77f3a0ff3e15de62502b132a4ae3a02628fca3725f2bf907" }, "downloads": -1, "filename": "graphql_ws_next-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e66c40dab5feccac94787dc689635ca0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 21191, "upload_time": "2018-09-21T00:28:24", "url": "https://files.pythonhosted.org/packages/62/1d/3323cf6f7acab2a74d3adaf28c4f3b8ba360560af0591341b4fa626f252e/graphql_ws_next-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d473e25d208b2baf5f548d894efc906b", "sha256": "423ce220833b55fc571d3a8c3b733c908672aecaba2546703eb24acd61dcfeb7" }, "downloads": -1, "filename": "graphql-ws-next-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d473e25d208b2baf5f548d894efc906b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 7877, "upload_time": "2018-09-21T00:28:22", "url": "https://files.pythonhosted.org/packages/9b/08/90ba55f8ccdcc877f3ea5fcae10007955db64daa82bf4db915f346c52a4b/graphql-ws-next-1.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e66c40dab5feccac94787dc689635ca0", "sha256": "d76a019ea64730af77f3a0ff3e15de62502b132a4ae3a02628fca3725f2bf907" }, "downloads": -1, "filename": "graphql_ws_next-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e66c40dab5feccac94787dc689635ca0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.6,<4.0", "size": 21191, "upload_time": "2018-09-21T00:28:24", "url": "https://files.pythonhosted.org/packages/62/1d/3323cf6f7acab2a74d3adaf28c4f3b8ba360560af0591341b4fa626f252e/graphql_ws_next-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d473e25d208b2baf5f548d894efc906b", "sha256": "423ce220833b55fc571d3a8c3b733c908672aecaba2546703eb24acd61dcfeb7" }, "downloads": -1, "filename": "graphql-ws-next-1.0.0.tar.gz", "has_sig": false, "md5_digest": "d473e25d208b2baf5f548d894efc906b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6,<4.0", "size": 7877, "upload_time": "2018-09-21T00:28:22", "url": "https://files.pythonhosted.org/packages/9b/08/90ba55f8ccdcc877f3ea5fcae10007955db64daa82bf4db915f346c52a4b/graphql-ws-next-1.0.0.tar.gz" } ] }