Skip to content

Commit 740e988

Browse files
authored
Add the warning from PR #530 in the stable branch (#533)
* Restrict graphql-core to <3.2.4 to fix tests
1 parent 9604113 commit 740e988

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

gql/transport/aiohttp.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,19 @@
33
import io
44
import json
55
import logging
6+
import warnings
67
from ssl import SSLContext
7-
from typing import Any, AsyncGenerator, Callable, Dict, Optional, Tuple, Type, Union
8+
from typing import (
9+
Any,
10+
AsyncGenerator,
11+
Callable,
12+
Dict,
13+
Optional,
14+
Tuple,
15+
Type,
16+
Union,
17+
cast,
18+
)
819

920
import aiohttp
1021
from aiohttp.client_exceptions import ClientResponseError
@@ -46,7 +57,7 @@ def __init__(
4657
headers: Optional[LooseHeaders] = None,
4758
cookies: Optional[LooseCookies] = None,
4859
auth: Optional[Union[BasicAuth, "AppSyncAuthentication"]] = None,
49-
ssl: Union[SSLContext, bool, Fingerprint] = False,
60+
ssl: Union[SSLContext, bool, Fingerprint, str] = "ssl_warning",
5061
timeout: Optional[int] = None,
5162
ssl_close_timeout: Optional[Union[int, float]] = 10,
5263
json_serialize: Callable = json.dumps,
@@ -74,7 +85,20 @@ def __init__(
7485
self.headers: Optional[LooseHeaders] = headers
7586
self.cookies: Optional[LooseCookies] = cookies
7687
self.auth: Optional[Union[BasicAuth, "AppSyncAuthentication"]] = auth
77-
self.ssl: Union[SSLContext, bool, Fingerprint] = ssl
88+
89+
if ssl == "ssl_warning":
90+
ssl = False
91+
if str(url).startswith("https"):
92+
warnings.warn(
93+
"WARNING: By default, AIOHTTPTransport does not verify"
94+
" ssl certificates. This will be fixed in the next major version."
95+
" You can set ssl=True to force the ssl certificate verification"
96+
" or ssl=False to disable this warning"
97+
)
98+
99+
self.ssl: Union[SSLContext, bool, Fingerprint] = cast(
100+
Union[SSLContext, bool, Fingerprint], ssl
101+
)
78102
self.timeout: Optional[int] = timeout
79103
self.ssl_close_timeout: Optional[Union[int, float]] = ssl_close_timeout
80104
self.client_session_args = client_session_args

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
install_requires = [
6-
"graphql-core>=3.2,<3.3",
6+
"graphql-core>=3.2,<3.2.4",
77
"yarl>=1.6,<2.0",
88
"backoff>=1.11.1,<3.0",
99
"anyio>=3.0,<5",
@@ -20,7 +20,8 @@
2020
"pytest-console-scripts==1.3.1",
2121
"pytest-cov==3.0.0",
2222
"mock==4.0.2",
23-
"vcrpy==4.4.0",
23+
"vcrpy==4.4.0;python_version<='3.8'",
24+
"vcrpy==7.0.0;python_version>'3.8'",
2425
"aiofiles",
2526
]
2627

0 commit comments

Comments
 (0)