Skip to content
Open
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
16 changes: 11 additions & 5 deletions gql/transport/websockets_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,12 +479,18 @@ async def _after_connect(self):
# Find the backend subprotocol returned in the response headers
try:
self.subprotocol = self.response_headers["Sec-WebSocket-Protocol"]
log.debug(f"backend subprotocol returned: {self.subprotocol!r}")
except KeyError:
# If the server does not send the subprotocol header, using
# the apollo subprotocol by default
self.subprotocol = self.APOLLO_SUBPROTOCOL

log.debug(f"backend subprotocol returned: {self.subprotocol!r}")
# If the server does not send the subprotocol header, use
# the apollo subprotocol by default unless we didn't ask for it
if (
self.adapter.subprotocols is None
or self.APOLLO_SUBPROTOCOL in self.adapter.subprotocols
):
self.subprotocol = self.APOLLO_SUBPROTOCOL
else:
self.subprotocol = self.GRAPHQLWS_SUBPROTOCOL
log.debug(f"backend returned no subprotocol, using: {self.subprotocol!r}")

async def _after_initialize(self):

Expand Down
Loading