Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wire httpx transport in gql-cli #513

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
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
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
Loading