Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion gql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,23 @@ def autodetect_transport(url: URL) -> str:

else:
assert url.scheme in ["http", "https"]
transport_name = "aiohttp"

try:
from gql.transport.aiohttp import AIOHTTPTransport # noqa: F401

transport_name = "aiohttp"
except ModuleNotFoundError: # pragma: no cover
try:
from gql.transport.httpx import HTTPXAsyncTransport # noqa: F401

transport_name = "httpx"
except ModuleNotFoundError:
raise ModuleNotFoundError(
"\n\nNo suitable dependencies has been found for an http(s) backend"
" (aiohttp or httpx).\n\n"
"Please check the install documentation at:\n"
"https://gql.readthedocs.io/en/stable/intro.html#installation\n"
)

return transport_name

Expand Down Expand Up @@ -462,6 +478,9 @@ async def main(args: Namespace) -> int:
except ValueError as e:
print(f"Error: {e}", file=sys.stderr)
return 1
except ModuleNotFoundError as e: # pragma: no cover
print(f"Error: {e}", file=sys.stderr)
return 2

# By default, the exit_code is 0 (everything is ok)
exit_code = 0
Expand Down
Loading