Skip to content

Commit b7c5865

Browse files
authored
Wire httpx transport in gql-cli (#513)
1 parent b2f2a68 commit b7c5865

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

gql/cli.py

+6
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def get_parser(with_examples: bool = False) -> ArgumentParser:
157157
choices=[
158158
"auto",
159159
"aiohttp",
160+
"httpx",
160161
"phoenix",
161162
"websockets",
162163
"aiohttp_websockets",
@@ -330,6 +331,11 @@ def get_transport(args: Namespace) -> Optional[AsyncTransport]:
330331

331332
return AIOHTTPTransport(url=args.server, **transport_args)
332333

334+
elif transport_name == "httpx":
335+
from gql.transport.httpx import HTTPXAsyncTransport
336+
337+
return HTTPXAsyncTransport(url=args.server, **transport_args)
338+
333339
elif transport_name == "phoenix":
334340
from gql.transport.phoenix_channel_websockets import (
335341
PhoenixChannelWebsocketsTransport,

tests/test_cli.py

+16
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ def test_cli_get_transport_aiohttp(parser, url):
190190
assert isinstance(transport, AIOHTTPTransport)
191191

192192

193+
@pytest.mark.httpx
194+
@pytest.mark.parametrize(
195+
"url",
196+
["http://your_server.com", "https://your_server.com"],
197+
)
198+
def test_cli_get_transport_httpx(parser, url):
199+
200+
from gql.transport.httpx import HTTPXAsyncTransport
201+
202+
args = parser.parse_args([url, "--transport", "httpx"])
203+
204+
transport = get_transport(args)
205+
206+
assert isinstance(transport, HTTPXAsyncTransport)
207+
208+
193209
@pytest.mark.websockets
194210
@pytest.mark.parametrize(
195211
"url",

0 commit comments

Comments
 (0)