Skip to content

A GraphQL WebSocket server and client to facilitate GraphQL queries, mutations and subscriptions over WebSocket

License

Notifications You must be signed in to change notification settings

DiamondLightSource/graphql-ws-aiohttp

Repository files navigation

graphql-ws-aiohttp

Code CI Test Coverage Latest PyPI version Apache License

Port of graphql-ws-next for graphql-core v3.

A GraphQL WebSocket server and client to facilitate GraphQL queries, mutations and subscriptions over WebSocket (for Python 3.6+). This code is based on the current implementation of subscriptions-transport-ws.

PyPI pip install graphql-ws-aiohttp
Source code https://github.com/dls-controls/graphql-ws-aiohttp
Changelog https://github.com/dls-controls/graphql-ws-aiohttp/blob/master/CHANGELOG.rst

Getting Started

Start by installing the package using pip:

Or, by using your favorite package manager, like Poetry:

With aiohttp

Usage with aiohttp is simple:

For other frameworks

Adding support for other web frameworks is simple. A framework must provide a concrete implementation of graphql_ws.abc.AbstractConnectionContext, and then it's ready to use with the SubscriptionServer.

Usage

Using apollo-link-ws you can opt to use websockets for queries and mutations in addition to subscriptions.

Use it with GraphiQL

Look in the demo<./demo>_ directory to see usage examples for GraphiQL. Due to the implementation of the javascript client for GraphiQL (GraphiQL-Subscriptions-Fetcher), queries and mutations will not be handled over websocket.

Contributing

This project uses Poetry, so to contribute, simply fork and clone this repository, and then set up your virtual environment using:

If you don't yet have Poetry installed, please follow the documentation for installation.

Code formatting is done via black, and code should be well-typed using mypy.

License

This package is licensed under the MIT License.

About

A GraphQL WebSocket server and client to facilitate GraphQL queries, mutations and subscriptions over WebSocket

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages