Skip to content

Commit 16c76bf

Browse files
committed
Merge branch 'master' into stable
2 parents 2dd1adb + dba4953 commit 16c76bf

File tree

165 files changed

+11572
-4984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+11572
-4984
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ assignees: ''
99

1010
**Common problems**
1111
- If you receive a TransportQueryError, it means the error is coming from the backend (See [Error Handling](https://gql.readthedocs.io/en/latest/advanced/error_handling.html)) and has probably nothing to do with gql
12-
- If you use IPython (Jupyter, Spyder), then [you need to use the async version](https://gql.readthedocs.io/en/latest/async/async_usage.html#ipython)
12+
- If you use IPython (Jupyter, Spyder), then [you need to use the async version](https://gql.readthedocs.io/en/latest/usage/async_usage.html#ipython)
1313
- Before sending a bug report, please consider [activating debug logs](https://gql.readthedocs.io/en/latest/advanced/logging.html) to see the messages exchanged between the client and the backend
1414

1515
**Describe the bug**

.github/workflows/deploy.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ jobs:
1010
runs-on: ubuntu-24.04
1111

1212
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python 3.8
15-
uses: actions/setup-python@v4
13+
- uses: actions/checkout@v4
14+
- name: Set up Python 3.12
15+
uses: actions/setup-python@v5
1616
with:
17-
python-version: 3.8
18-
- name: Build wheel and source tarball
17+
python-version: 3.12
18+
- name: Install build dependencies
1919
run: |
20-
pip install wheel
21-
python setup.py sdist bdist_wheel
20+
python -m pip install --upgrade pip
21+
pip install build wheel
22+
- name: Build package
23+
run: |
24+
python -m build
2225
- name: Publish a Python distribution to PyPI
23-
uses: pypa/gh-action-pypi-publish@v1.1.0
26+
uses: pypa/gh-action-pypi-publish@release/v1
2427
with:
25-
user: __token__
2628
password: ${{ secrets.pypi_password }}

.github/workflows/lint.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
name: Lint
22

3+
permissions:
4+
contents: read
5+
36
on: [push, pull_request]
47

58
jobs:
69
build:
710
runs-on: ubuntu-24.04
811

912
steps:
10-
- uses: actions/checkout@v3
11-
- name: Set up Python 3.8
12-
uses: actions/setup-python@v4
13+
- uses: actions/checkout@v4
14+
- name: Set up Python 3.12
15+
uses: actions/setup-python@v5
1316
with:
14-
python-version: 3.8
17+
python-version: 3.12
1518
- name: Install dependencies
1619
run: |
1720
python -m pip install --upgrade pip wheel

.github/workflows/tests.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Tests
22

3+
permissions:
4+
contents: read
5+
36
on: [push, pull_request]
47

58
jobs:
@@ -8,7 +11,7 @@ jobs:
811
strategy:
912
max-parallel: 4
1013
matrix:
11-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.8"]
14+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]
1215
os: [ubuntu-24.04, windows-latest]
1316
exclude:
1417
- os: windows-latest
@@ -18,14 +21,14 @@ jobs:
1821
- os: windows-latest
1922
python-version: "3.11"
2023
- os: windows-latest
21-
python-version: "3.12"
24+
python-version: "3.13"
2225
- os: windows-latest
23-
python-version: "pypy3.8"
26+
python-version: "pypy3.10"
2427

2528
steps:
26-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
2730
- name: Set up Python ${{ matrix.python-version }}
28-
uses: actions/setup-python@v4
31+
uses: actions/setup-python@v5
2932
with:
3033
python-version: ${{ matrix.python-version }}
3134
- name: Install dependencies
@@ -45,11 +48,11 @@ jobs:
4548
dependency: ["aiohttp", "requests", "httpx", "websockets"]
4649

4750
steps:
48-
- uses: actions/checkout@v3
49-
- name: Set up Python 3.8
50-
uses: actions/setup-python@v4
51+
- uses: actions/checkout@v4
52+
- name: Set up Python 3.12
53+
uses: actions/setup-python@v5
5154
with:
52-
python-version: 3.8
55+
python-version: 3.12
5356
- name: Install dependencies with only ${{ matrix.dependency }} extra dependency
5457
run: |
5558
python -m pip install --upgrade pip wheel
@@ -60,17 +63,24 @@ jobs:
6063
coverage:
6164
runs-on: ubuntu-24.04
6265

66+
permissions:
67+
contents: read
68+
checks: write
69+
6370
steps:
64-
- uses: actions/checkout@v3
65-
- name: Set up Python 3.8
66-
uses: actions/setup-python@v4
71+
- uses: actions/checkout@v4
72+
- name: Set up Python 3.12
73+
uses: actions/setup-python@v5
6774
with:
68-
python-version: 3.8
75+
python-version: 3.12
6976
- name: Install test dependencies
7077
run: |
7178
python -m pip install --upgrade pip wheel
7279
pip install -e.[test]
7380
- name: Test with coverage
7481
run: pytest --cov=gql --cov-report=xml --cov-report=term-missing tests
7582
- name: Upload coverage to Codecov
76-
uses: codecov/codecov-action@v1
83+
uses: codecov/codecov-action@v4
84+
with:
85+
fail_ci_if_error: false
86+
token: ${{ secrets.CODECOV_TOKEN }}

MANIFEST.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ include README.md
66
include CONTRIBUTING.md
77
include .readthedocs.yaml
88

9-
include dev_requirements.txt
109
include Makefile
1110

1211
include tox.ini
1312

1413
include gql/py.typed
1514

16-
recursive-include tests *.py *.graphql *.cnf *.yaml *.pem
17-
recursive-include docs *.txt *.rst conf.py Makefile make.bat *.jpg *.png *.gif
15+
recursive-include tests *.py *.graphql *.cnf *.yaml *.pem *.crt
16+
recursive-include docs *.txt *.rst conf.py Makefile make.bat
1817
recursive-include docs/code_examples *.py
1918

2019
prune docs/_build
21-
prune gql-checker
2220

2321
global-exclude *.py[co] __pycache__

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ tests_websockets:
2424
pytest tests --websockets-only
2525

2626
check:
27-
isort --recursive $(SRC_PYTHON)
27+
isort $(SRC_PYTHON)
2828
black $(SRC_PYTHON)
2929
flake8 $(SRC_PYTHON)
3030
mypy $(SRC_PYTHON)

README.md

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# GQL
22

3-
This is a GraphQL client for Python 3.7+.
4-
Plays nicely with `graphene`, `graphql-core`, `graphql-js` and any other GraphQL implementation compatible with the spec.
3+
This is a GraphQL client for Python.
4+
Plays nicely with `graphene`, `graphql-core`, `graphql-js` and any other GraphQL implementation
5+
compatible with the [GraphQL specification](https://spec.graphql.org).
56

67
GQL architecture is inspired by `React-Relay` and `Apollo-Client`.
78

@@ -37,9 +38,10 @@ The complete documentation for GQL can be found at
3738
* AWS AppSync realtime protocol (experimental)
3839
* Possibility to [validate the queries locally](https://gql.readthedocs.io/en/latest/usage/validation.html) using a GraphQL schema provided locally or fetched from the backend using an instrospection query
3940
* Supports GraphQL queries, mutations and [subscriptions](https://gql.readthedocs.io/en/latest/usage/subscriptions.html)
40-
* Supports [sync or async usage](https://gql.readthedocs.io/en/latest/async/index.html), [allowing concurrent requests](https://gql.readthedocs.io/en/latest/advanced/async_advanced_usage.html#async-advanced-usage)
41+
* Supports [sync](https://gql.readthedocs.io/en/latest/usage/sync_usage.html) or [async](https://gql.readthedocs.io/en/latest/usage/async_usage.html) usage, [allowing concurrent requests](https://gql.readthedocs.io/en/latest/advanced/async_advanced_usage.html#async-advanced-usage)
4142
* Supports [File uploads](https://gql.readthedocs.io/en/latest/usage/file_upload.html)
4243
* Supports [Custom scalars / Enums](https://gql.readthedocs.io/en/latest/usage/custom_scalars_and_enums.html)
44+
* Supports [Batching requests](https://gql.readthedocs.io/en/latest/advanced/batching_requests.html)
4345
* [gql-cli script](https://gql.readthedocs.io/en/latest/gql-cli/intro.html) to execute GraphQL queries or download schemas from the command line
4446
* [DSL module](https://gql.readthedocs.io/en/latest/advanced/dsl_module.html) to compose GraphQL queries dynamically
4547

@@ -56,17 +58,17 @@ pip install "gql[all]"
5658
5759
## Usage
5860

59-
### Basic usage
61+
### Sync usage
6062

6163
```python
62-
from gql import gql, Client
64+
from gql import Client, gql
6365
from gql.transport.aiohttp import AIOHTTPTransport
6466

6567
# Select your transport with a defined url endpoint
6668
transport = AIOHTTPTransport(url="https://countries.trevorblades.com/")
6769

6870
# Create a GraphQL client using the defined transport
69-
client = Client(transport=transport, fetch_schema_from_transport=True)
71+
client = Client(transport=transport)
7072

7173
# Provide a GraphQL query
7274
query = gql(
@@ -94,7 +96,48 @@ $ python basic_example.py
9496

9597
> **WARNING**: Please note that this basic example won't work if you have an asyncio event loop running. In some
9698
> python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you. In that case you
97-
> should use instead the [async usage example](https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage).
99+
> should use instead the [async usage example](https://gql.readthedocs.io/en/latest/usage/async_usage.html#async-usage).
100+
101+
### Async usage
102+
103+
```python
104+
import asyncio
105+
106+
from gql import Client, gql
107+
from gql.transport.aiohttp import AIOHTTPTransport
108+
109+
110+
async def main():
111+
112+
# Select your transport with a defined url endpoint
113+
transport = AIOHTTPTransport(url="https://countries.trevorblades.com/graphql")
114+
115+
# Create a GraphQL client using the defined transport
116+
client = Client(transport=transport)
117+
118+
# Provide a GraphQL query
119+
query = gql(
120+
"""
121+
query getContinents {
122+
continents {
123+
code
124+
name
125+
}
126+
}
127+
"""
128+
)
129+
130+
# Using `async with` on the client will start a connection on the transport
131+
# and provide a `session` variable to execute queries on this connection
132+
async with client as session:
133+
134+
# Execute the query
135+
result = await session.execute(query)
136+
print(result)
137+
138+
139+
asyncio.run(main())
140+
```
98141

99142
## Contributing
100143
See [CONTRIBUTING.md](CONTRIBUTING.md)

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line, and also
55
# from the environment for the first two.
6-
SPHINXOPTS ?=
6+
SPHINXOPTS ?= -n
77
SPHINXBUILD ?= sphinx-build
88
SOURCEDIR = .
99
BUILDDIR = _build

docs/advanced/async_permanent_session.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ backoff decorator to the :code:`retry_execute` argument.
7575
backoff.expo,
7676
Exception,
7777
max_tries=3,
78-
giveup=lambda e: isinstance(e, TransportQueryError),
7978
)
8079
session = await client.connect_async(
8180
reconnecting=True,
@@ -84,6 +83,18 @@ backoff decorator to the :code:`retry_execute` argument.
8483
8584
If you don't want any retry on the execute calls, you can disable the retries with :code:`retry_execute=False`
8685

86+
.. note::
87+
If you want to retry even with :code:`TransportQueryError` exceptions,
88+
then you need to make your own backoff decorator on your own method:
89+
90+
.. code-block:: python
91+
92+
@backoff.on_exception(backoff.expo,
93+
Exception,
94+
max_tries=3)
95+
async def execute_with_retry(session, query):
96+
return await session.execute(query)
97+
8798
Subscription retries
8899
^^^^^^^^^^^^^^^^^^^^
89100

0 commit comments

Comments
 (0)