Skip to content

PhoenixChannelWebsocketsTransport inherits WebsocketsTransportBase #280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gql/transport/phoenix_channel_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
TransportQueryError,
TransportServerError,
)
from .websockets import WebsocketsTransport
from .websockets_base import WebsocketsTransportBase

log = logging.getLogger(__name__)

Expand All @@ -24,7 +24,7 @@ def __init__(self, query_id: int) -> None:
self.unsubscribe_id: Optional[int] = None


class PhoenixChannelWebsocketsTransport(WebsocketsTransport):
class PhoenixChannelWebsocketsTransport(WebsocketsTransportBase):
"""The PhoenixChannelWebsocketsTransport is an async transport
which allows you to execute queries and subscriptions against an `Absinthe`_
backend using the `Phoenix`_ framework `channels`_.
Expand Down Expand Up @@ -54,7 +54,7 @@ def __init__(
self.subscriptions: Dict[str, Subscription] = {}
super(PhoenixChannelWebsocketsTransport, self).__init__(*args, **kwargs)

async def _send_init_message_and_wait_ack(self) -> None:
async def _initialize(self) -> None:
"""Join the specified channel and wait for the connection ACK.

If the answer is not a connection_ack message, we will return an Exception.
Expand Down Expand Up @@ -131,6 +131,9 @@ async def _send_stop_message(self, query_id: int) -> None:

await self._send(unsubscribe_message)

async def _stop_listener(self, query_id: int) -> None:
await self._send_stop_message(query_id)

async def _send_connection_terminate_message(self) -> None:
"""Send a phx_leave message to disconnect from the provided channel."""

Expand All @@ -148,6 +151,9 @@ async def _send_connection_terminate_message(self) -> None:

await self._send(connection_terminate_message)

async def _connection_terminate(self):
await self._send_connection_terminate_message()

async def _send_query(
self,
document: DocumentNode,
Expand Down