Skip to content

Commit

Permalink
Wire httpx transport in gql-cli (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
mss authored Dec 11, 2024
1 parent b2f2a68 commit b7c5865
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def get_parser(with_examples: bool = False) -> ArgumentParser:
choices=[
"auto",
"aiohttp",
"httpx",
"phoenix",
"websockets",
"aiohttp_websockets",
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit b7c5865

Please sign in to comment.