File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -297,7 +297,23 @@ def autodetect_transport(url: URL) -> str:
297297
298298 else :
299299 assert url .scheme in ["http" , "https" ]
300- transport_name = "aiohttp"
300+
301+ try :
302+ from gql .transport .aiohttp import AIOHTTPTransport # noqa: F401
303+
304+ transport_name = "aiohttp"
305+ except ModuleNotFoundError : # pragma: no cover
306+ try :
307+ from gql .transport .httpx import HTTPXAsyncTransport # noqa: F401
308+
309+ transport_name = "httpx"
310+ except ModuleNotFoundError :
311+ raise ModuleNotFoundError (
312+ "\n \n No suitable dependencies has been found for an http(s) backend"
313+ " (aiohttp or httpx).\n \n "
314+ "Please check the install documentation at:\n "
315+ "https://gql.readthedocs.io/en/stable/intro.html#installation\n "
316+ )
301317
302318 return transport_name
303319
@@ -462,6 +478,9 @@ async def main(args: Namespace) -> int:
462478 except ValueError as e :
463479 print (f"Error: { e } " , file = sys .stderr )
464480 return 1
481+ except ModuleNotFoundError as e : # pragma: no cover
482+ print (f"Error: { e } " , file = sys .stderr )
483+ return 2
465484
466485 # By default, the exit_code is 0 (everything is ok)
467486 exit_code = 0
You can’t perform that action at this time.
0 commit comments