Skip to content

Commit

Permalink
Add reference documentation + remove deprecated ssl_context param
Browse files Browse the repository at this point in the history
  • Loading branch information
leszekhanusz committed Jul 15, 2024
1 parent 6906ad2 commit 4ea698f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/modules/gql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Sub-Packages
client
transport
transport_aiohttp
transport_aiohttp_websockets
transport_appsync_auth
transport_appsync_websockets
transport_exceptions
Expand Down
7 changes: 7 additions & 0 deletions docs/modules/transport_aiohttp_websockets.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
gql.transport.aiohttp_websockets
================================

.. currentmodule:: gql.transport.aiohttp_websockets

.. automodule:: gql.transport.aiohttp_websockets
:member-order: bysource
82 changes: 79 additions & 3 deletions gql/transport/aiohttp_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def __init__(
proxy_auth: Optional[BasicAuth] = None,
proxy_headers: Optional[LooseHeaders] = None,
ssl: Optional[Union[SSLContext, Literal[False], Fingerprint]] = None,
ssl_context: Optional[SSLContext] = None,
websocket_close_timeout: float = 10.0,
receive_timeout: Optional[float] = None,
ssl_close_timeout: Optional[Union[int, float]] = 10,
Expand All @@ -135,6 +134,85 @@ def __init__(
client_session_args: Optional[Dict[str, Any]] = None,
connect_args: Dict[str, Any] = {},
) -> None:
"""Initialize the transport with the given parameters.
:param url: The GraphQL server URL. Example: 'wss://server.com:PORT/graphql'.
:param subprotocols: list of subprotocols sent to the
backend in the 'subprotocols' http header.
By default: both apollo and graphql-ws subprotocols.
:param float heartbeat: Send low level `ping` message every `heartbeat`
seconds and wait `pong` response, close
connection if `pong` response is not
received. The timer is reset on any data reception.
:param auth: An object that represents HTTP Basic Authorization.
:class:`~aiohttp.BasicAuth` (optional)
:param str origin: Origin header to send to server(optional)
:param params: Mapping, iterable of tuple of *key*/*value* pairs or
string to be sent as parameters in the query
string of the new request. Ignored for subsequent
redirected requests (optional)
Allowed values are:
- :class:`collections.abc.Mapping` e.g. :class:`dict`,
:class:`multidict.MultiDict` or
:class:`multidict.MultiDictProxy`
- :class:`collections.abc.Iterable` e.g. :class:`tuple` or
:class:`list`
- :class:`str` with preferably url-encoded content
(**Warning:** content will not be encoded by *aiohttp*)
:param headers: HTTP Headers that sent with every request
May be either *iterable of key-value pairs* or
:class:`~collections.abc.Mapping`
(e.g. :class:`dict`,
:class:`~multidict.CIMultiDict`).
:param proxy: Proxy URL, :class:`str` or :class:`~yarl.URL` (optional)
:param aiohttp.BasicAuth proxy_auth: an object that represents proxy HTTP
Basic Authorization (optional)
:param ssl: SSL validation mode. ``True`` for default SSL check
(:func:`ssl.create_default_context` is used),
``False`` for skip SSL certificate validation,
:class:`aiohttp.Fingerprint` for fingerprint
validation, :class:`ssl.SSLContext` for custom SSL
certificate validation.
:param float websocket_close_timeout: Timeout for websocket to close.
``10`` seconds by default
:param float receive_timeout: Timeout for websocket to receive
complete message. ``None`` (unlimited)
seconds by default
:param ssl_close_timeout: Timeout in seconds to wait for the ssl connection
to close properly
:param connect_timeout: Timeout in seconds for the establishment
of the websocket connection. If None is provided this will wait forever.
:param close_timeout: Timeout in seconds for the close. If None is provided
this will wait forever.
:param ack_timeout: Timeout in seconds to wait for the connection_ack message
from the server. If None is provided this will wait forever.
:param keep_alive_timeout: Optional Timeout in seconds to receive
a sign of liveness from the server.
:param init_payload: Dict of the payload sent in the connection_init message.
:param ping_interval: Delay in seconds between pings sent by the client to
the backend for the graphql-ws protocol. None (by default) means that
we don't send pings. Note: there are also pings sent by the underlying
websockets protocol. See the
:ref:`keepalive documentation <websockets_transport_keepalives>`
for more information about this.
:param pong_timeout: Delay in seconds to receive a pong from the backend
after we sent a ping (only for the graphql-ws protocol).
By default equal to half of the ping_interval.
:param answer_pings: Whether the client answers the pings from the backend
(for the graphql-ws protocol).
By default: True
:param client_session_args: Dict of extra args passed to
`aiohttp.ClientSession`_
:param connect_args: Dict of extra args passed to
`aiohttp.ClientSession.ws_connect`_
.. _aiohttp.ClientSession.ws_connect:
https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession.ws_connect
.. _aiohttp.ClientSession:
https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession
"""
self.url: StrOrURL = url
self.heartbeat: Optional[float] = heartbeat
self.auth: Optional[BasicAuth] = auth
Expand All @@ -147,7 +225,6 @@ def __init__(
self.proxy_headers: Optional[LooseHeaders] = proxy_headers

self.ssl: Optional[Union[SSLContext, Literal[False], Fingerprint]] = ssl
self.ssl_context: Optional[SSLContext] = ssl_context

self.websocket_close_timeout: float = websocket_close_timeout
self.receive_timeout: Optional[float] = receive_timeout
Expand Down Expand Up @@ -803,7 +880,6 @@ async def connect(self) -> None:
timeout=self.websocket_close_timeout,
receive_timeout=self.receive_timeout,
ssl=self.ssl,
ssl_context=None,
**connect_args,
),
self.connect_timeout,
Expand Down

0 comments on commit 4ea698f

Please sign in to comment.