dchusovitin / gql-actioncable

graphql-python/gql transport for the ActionCable websockets protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gql-actioncable

This is a graphql-python/gql transport for the ActionCable websockets protocol.

Installation

You can install the transport with:

pip install gqlactioncable

Usage

Here is an example using the sorare.com GraphQL websockets backend:

import asyncio

from gql import Client, gql

from gqlactioncable import ActionCableWebsocketsTransport


async def main():

    transport = ActionCableWebsocketsTransport(
        url="wss://ws.sorare.com/cable",
    )

    async with Client(transport=transport) as session:

        subscription = gql(
            """
            subscription onAnyCardUpdated {
              aCardWasUpdated {
                slug
              }
            }
        """
        )

        async for result in session.subscribe(subscription):
            print(result)


asyncio.run(main())

License

MIT License

About

graphql-python/gql transport for the ActionCable websockets protocol

License:MIT License


Languages

Language:Python 94.6%Language:Makefile 5.4%