diff --git a/gql/cli.py b/gql/cli.py index a7d129e2..06781c2b 100644 --- a/gql/cli.py +++ b/gql/cli.py @@ -157,6 +157,7 @@ def get_parser(with_examples: bool = False) -> ArgumentParser: choices=[ "auto", "aiohttp", + "httpx", "phoenix", "websockets", "aiohttp_websockets", @@ -330,6 +331,11 @@ def get_transport(args: Namespace) -> Optional[AsyncTransport]: return AIOHTTPTransport(url=args.server, **transport_args) + elif transport_name == "httpx": + from gql.transport.httpx import HTTPXAsyncTransport + + return HTTPXAsyncTransport(url=args.server, **transport_args) + elif transport_name == "phoenix": from gql.transport.phoenix_channel_websockets import ( PhoenixChannelWebsocketsTransport, diff --git a/tests/test_cli.py b/tests/test_cli.py index 88d1f533..dccfcb5a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -190,6 +190,22 @@ def test_cli_get_transport_aiohttp(parser, url): assert isinstance(transport, AIOHTTPTransport) +@pytest.mark.httpx +@pytest.mark.parametrize( + "url", + ["http://your_server.com", "https://your_server.com"], +) +def test_cli_get_transport_httpx(parser, url): + + from gql.transport.httpx import HTTPXAsyncTransport + + args = parser.parse_args([url, "--transport", "httpx"]) + + transport = get_transport(args) + + assert isinstance(transport, HTTPXAsyncTransport) + + @pytest.mark.websockets @pytest.mark.parametrize( "url",