Skip to content

Commit

Permalink
Add the warning from PR #530 in the stable branch (#533)
Browse files Browse the repository at this point in the history
* Restrict graphql-core to <3.2.4 to fix tests
  • Loading branch information
leszekhanusz authored Feb 19, 2025
1 parent 9604113 commit 740e988
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 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
5 changes: 3 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

install_requires = [
"graphql-core>=3.2,<3.3",
"graphql-core>=3.2,<3.2.4",
"yarl>=1.6,<2.0",
"backoff>=1.11.1,<3.0",
"anyio>=3.0,<5",
Expand All @@ -20,7 +20,8 @@
"pytest-console-scripts==1.3.1",
"pytest-cov==3.0.0",
"mock==4.0.2",
"vcrpy==4.4.0",
"vcrpy==4.4.0;python_version<='3.8'",
"vcrpy==7.0.0;python_version>'3.8'",
"aiofiles",
]

Expand Down

0 comments on commit 740e988

Please # to comment.