Skip to content

Allways pull in deps for working gql-cli #527

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

Closed
wants to merge 1 commit into from

Conversation

traylenator
Copy link

As things stand:

$ pip3 install gql

$ echo 'query { continent(code:"AF") { name } }' | gql-cli https://countries.trevorblades.com
Traceback (most recent call last):
  File "/home/steve/tests/bin/gql-cli", line 8, in <module>
    sys.exit(gql_cli())
             ~~~~~~~^^
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/cli.py", line 534, in gql_cli
    exit_code = loop.run_until_complete(main_task)
  File "/usr/lib64/python3.13/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/cli.py", line 436, in main
    transport = get_transport(args)
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/cli.py", line 323, in get_transport
    from gql.transport.aiohttp import AIOHTTPTransport
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/transport/aiohttp.py", line 9, in <module>
    import aiohttp
ModuleNotFoundError: No module named 'aiohttp'

The aiohttp dependencies are really allways needed for CLI to work.

This patch makes aiohttp an install_require rather than be required as an optional sub package.

As things stand:

```
$ pip3 install gql

$ echo 'query { continent(code:"AF") { name } }' | gql-cli https://countries.trevorblades.com
Traceback (most recent call last):
  File "/home/steve/tests/bin/gql-cli", line 8, in <module>
    sys.exit(gql_cli())
             ~~~~~~~^^
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/cli.py", line 534, in gql_cli
    exit_code = loop.run_until_complete(main_task)
  File "/usr/lib64/python3.13/asyncio/base_events.py", line 720, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/cli.py", line 436, in main
    transport = get_transport(args)
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/cli.py", line 323, in get_transport
    from gql.transport.aiohttp import AIOHTTPTransport
  File "/home/steve/tests/lib64/python3.13/site-packages/gql/transport/aiohttp.py", line 9, in <module>
    import aiohttp
ModuleNotFoundError: No module named 'aiohttp'
```

The aiohttp dependencies are really allways needed for CLI to work.

This patch makes aiohttp an `install_require` rather than be required as an optional sub package.
@leszekhanusz
Copy link
Collaborator

leszekhanusz commented Jan 30, 2025

aiohttp is not always required for gql-cli to work, either by using a websockets backend, or by using httpx:

# without aiohttp but with httpx:
$ echo 'query { continent(code:"AF") { name } }' | gql-cli --transport httpx https://countries.trevorblades.com
{"continent": {"name": "Africa"}}

It is true that the autodetect_transport method could be improved so that if aiohttp is not installed and no transport is specified (auto), then it would select the httpx transport automatically.

I'll make a PR for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants