Skip to content

Commit

Permalink
Add the warning from PR graphql-python#530 in the stable branch
Browse files Browse the repository at this point in the history
  • Loading branch information
leszekhanusz committed Feb 18, 2025
1 parent 9604113 commit f14cff8
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions gql/transport/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
import io
import json
import logging
import warnings
from ssl import SSLContext
from typing import Any, AsyncGenerator, Callable, Dict, Optional, Tuple, Type, Union
from typing import (
Any,
AsyncGenerator,
Callable,
Dict,
Optional,
Tuple,
Type,
Union,
cast,
)

import aiohttp
from aiohttp.client_exceptions import ClientResponseError
Expand Down Expand Up @@ -46,7 +57,7 @@ def __init__(
headers: Optional[LooseHeaders] = None,
cookies: Optional[LooseCookies] = None,
auth: Optional[Union[BasicAuth, "AppSyncAuthentication"]] = None,
ssl: Union[SSLContext, bool, Fingerprint] = False,
ssl: Union[SSLContext, bool, Fingerprint, str] = "ssl_warning",
timeout: Optional[int] = None,
ssl_close_timeout: Optional[Union[int, float]] = 10,
json_serialize: Callable = json.dumps,
Expand Down Expand Up @@ -74,7 +85,20 @@ def __init__(
self.headers: Optional[LooseHeaders] = headers
self.cookies: Optional[LooseCookies] = cookies
self.auth: Optional[Union[BasicAuth, "AppSyncAuthentication"]] = auth
self.ssl: Union[SSLContext, bool, Fingerprint] = ssl

if ssl == "ssl_warning":
ssl = False
if str(url).startswith("https"):
warnings.warn(
"WARNING: By default, AIOHTTPTransport does not verify"
" ssl certificates. This will be fixed in the next major version."
" You can set ssl=True to force the ssl certificate verification"
" or ssl=False to disable this warning"
)

self.ssl: Union[SSLContext, bool, Fingerprint] = cast(
Union[SSLContext, bool, Fingerprint], ssl
)
self.timeout: Optional[int] = timeout
self.ssl_close_timeout: Optional[Union[int, float]] = ssl_close_timeout
self.client_session_args = client_session_args
Expand Down

0 comments on commit f14cff8

Please sign in to comment.