Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: graphql-python/gql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.5.0b5
Choose a base ref
...
head repository: graphql-python/gql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Sep 5, 2023

  1. Add sync batching to requests sync transport (#431)

    * Add `execute_batch` method for requests sync transport
    itolosa authored Sep 5, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d4c9751 View commit details

Commits on Sep 9, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    dfbcb59 View commit details

Commits on Sep 13, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ff3082b View commit details

Commits on Oct 4, 2023

  1. Bump vcrpy and requests_toolbelt (#440)

    * Bump vcrpy and remove urllib3 restriction
    * Restrict vcrpy to 4.4.0 to still support Python 3.7
    * Bump requests_toolbelt to 1.0.0 to make it work with urllib3 2.x
    leszekhanusz authored Oct 4, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d959ef4 View commit details
  2. Copy the full SHA
    c939573 View commit details

Commits on Oct 22, 2023

  1. Fix tests with Python 3.12 (#442)

    * Adding Python 3.12 to automated tests
    * Bumping `pytest` and `pytest_asyncio` versions
    * Fixing test cleanup for Python 3.12
    * Force aiohttp 3.9.0b0 version for Python version >= 3.12
    leszekhanusz authored Oct 22, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e0bd497 View commit details

Commits on Oct 23, 2023

  1. Copy the full SHA
    f273a2b View commit details
  2. Copy the full SHA
    87fac0f View commit details

Commits on Nov 14, 2023

  1. Fix parse_results with fragments (#446)

    * Fix issue #445
    leszekhanusz authored Nov 14, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ff6352b View commit details
  2. Copy the full SHA
    c5a164c View commit details

Commits on Nov 19, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    632ec96 View commit details
  2. Copy the full SHA
    3a48a2f View commit details

Commits on Nov 21, 2023

  1. Adding node_tree method in utilities to debug and compare DocumentNod…

    …e instances (#449)
    
    DSL: Set variable_definitions to None for Fragments by default instead of empty tuple
    leszekhanusz authored Nov 21, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a2f327f View commit details

Commits on Dec 15, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    528636a View commit details
  2. Copy the full SHA
    039236c View commit details

Commits on Jan 3, 2024

  1. Fix online tests using the countries.trevorblades.com backend (#459)

    * Remove http online tests - only https is supported on backend now
    * Skip online websockets tests - backend does not support it anymore
    * Skip/remove batching online tests as backend does not support it anymore
    * Remove 2 flaky online tests
    leszekhanusz authored Jan 3, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c23d3e0 View commit details
  2. Modify tests to work with multiple versions of graphql-core (#460)

    * Tests modified to work with multiple graphql-core versions regarding braces spaces
    * Modify gql to work before and after graphql-core 3.3.0a3 subscribe changes
    leszekhanusz authored Jan 3, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d14d1f4 View commit details
  3. Copy the full SHA
    aa1ffad View commit details
  4. Copy the full SHA
    9604113 View commit details
  5. Copy the full SHA
    e6a7873 View commit details

Commits on Jan 24, 2024

  1. Copy the full SHA
    3a641b1 View commit details

Commits on Feb 8, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    a3f0bd9 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e5c7c8f View commit details
  3. Copy the full SHA
    48bb94c View commit details

Commits on Mar 6, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    40f07cf View commit details

Commits on Mar 16, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9052403 View commit details

Commits on Apr 14, 2024

  1. Fix importing DirectiveLocation directly from graphql (#477)

    Should fix running gql with graphql-core 3.3.0a5
    leszekhanusz authored Apr 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ba53126 View commit details
  2. Copy the full SHA
    2363698 View commit details

Commits on Jul 13, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    8c33e8f View commit details

Commits on Jul 14, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    9f93215 View commit details
  2. Copy the full SHA
    8560593 View commit details
  3. Copy the full SHA
    e63ed0f View commit details
  4. Copy the full SHA
    ede1350 View commit details

Commits on Jul 25, 2024

  1. Copy the full SHA
    00b61d5 View commit details

Commits on Jul 28, 2024

  1. Copy the full SHA
    9af5146 View commit details

Commits on Aug 1, 2024

  1. Update annotation for client.execute_batch, get_execution_result argu… (

    #483)
    
    Co-authored-by: Hanusz Leszek <leszek.hanusz@gmail.com>
    rahul-gj and leszekhanusz authored Aug 1, 2024
    Copy the full SHA
    2ee2583 View commit details
  2. Copy the full SHA
    1c657d8 View commit details

Commits on Oct 27, 2024

  1. Copy the full SHA
    79dbe45 View commit details

Commits on Oct 28, 2024

  1. Copy the full SHA
    dbafcd0 View commit details
  2. Fix build wheel warnings (#503)

    * MANIFEST.in remove non-existing included files
    * setup.cfg Removing deprecated universal wheel option
    * Removing deprecated tests_require parameter
    leszekhanusz authored Oct 28, 2024
    Copy the full SHA
    013eebd View commit details
  3. Using unittest.mock instead of mock (#504)

    Also Running gql-cli --version test in subprocess mode to try to fix flaky test
    leszekhanusz authored Oct 28, 2024
    Copy the full SHA
    57ef910 View commit details
  4. Copy the full SHA
    e355261 View commit details
  5. Copy the full SHA
    c3b722e View commit details

Commits on Oct 29, 2024

  1. Copy the full SHA
    ff4a20a View commit details

Commits on Nov 16, 2024

  1. Copy the full SHA
    d074611 View commit details
  2. Copy the full SHA
    b2f2a68 View commit details

Commits on Dec 11, 2024

  1. Copy the full SHA
    b7c5865 View commit details
  2. Copy the full SHA
    5879e23 View commit details

Commits on Dec 12, 2024

  1. Copy the full SHA
    483053f View commit details

Commits on Jan 20, 2025

  1. Chore fix tests failing vcrpy urllib3 dep (#518)

    * Bump vcrpy to 7.0.0
    leszekhanusz authored Jan 20, 2025
    Copy the full SHA
    26b28d7 View commit details
Showing with 14,109 additions and 4,790 deletions.
  1. +1 −1 .github/ISSUE_TEMPLATE/bug_report.md
  2. +12 −10 .github/workflows/deploy.yml
  3. +8 −5 .github/workflows/lint.yml
  4. +28 −18 .github/workflows/tests.yml
  5. +0 −1 .readthedocs.yaml
  6. +2 −4 MANIFEST.in
  7. +1 −1 Makefile
  8. +50 −7 README.md
  9. +1 −1 docs/Makefile
  10. +12 −1 docs/advanced/async_permanent_session.rst
  11. +96 −0 docs/advanced/batching_requests.rst
  12. +5 −0 docs/advanced/error_handling.rst
  13. +1 −0 docs/advanced/index.rst
  14. +2 −12 docs/advanced/logging.rst
  15. +0 −18 docs/async/async_intro.rst
  16. +0 −10 docs/async/index.rst
  17. +18 −16 docs/code_examples/aiohttp_async.py
  18. +2 −0 docs/code_examples/aiohttp_async_dsl.py
  19. +1 −1 docs/code_examples/aiohttp_sync.py
  20. +50 −0 docs/code_examples/aiohttp_websockets_async.py
  21. +2 −2 docs/code_examples/appsync/mutation_api_key.py
  22. +2 −2 docs/code_examples/appsync/mutation_iam.py
  23. +8 −6 docs/code_examples/console_async.py
  24. +4 −3 docs/code_examples/fastapi_async.py
  25. +34 −0 docs/code_examples/httpx_async_trio.py
  26. +2 −2 docs/code_examples/reconnecting_mutation_http.py
  27. +2 −2 docs/code_examples/reconnecting_mutation_ws.py
  28. +54 −2 docs/conf.py
  29. +8 −6 docs/gql-cli/intro.rst
  30. +2 −3 docs/index.rst
  31. +34 −23 docs/intro.rst
  32. +6 −1 docs/modules/gql.rst
  33. +7 −0 docs/modules/transport_aiohttp_websockets.rst
  34. +7 −0 docs/modules/transport_common_adapters_aiohttp.rst
  35. +7 −0 docs/modules/transport_common_adapters_connection.rst
  36. +7 −0 docs/modules/transport_common_adapters_websockets.rst
  37. +7 −0 docs/modules/transport_common_base.rst
  38. +0 −7 docs/modules/transport_websockets_base.rst
  39. +7 −0 docs/modules/transport_websockets_protocol.rst
  40. +3 −1 docs/transports/aiohttp.rst
  41. +31 −0 docs/transports/aiohttp_websockets.rst
  42. +1 −0 docs/transports/async_transports.rst
  43. +21 −3 docs/{async → usage}/async_usage.rst
  44. +9 −14 docs/usage/custom_scalars_and_enums.rst
  45. +58 −50 docs/usage/file_upload.rst
  46. +2 −1 docs/usage/index.rst
  47. +55 −8 docs/usage/subscriptions.rst
  48. +4 −5 docs/usage/{basic_usage.rst → sync_usage.rst}
  49. +1 −1 docs/usage/validation.rst
  50. +5 −5 docs/usage/variables.rst
  51. +0 −9 gql-checker/.gitignore
  52. +0 −12 gql-checker/.travis.yml
  53. +0 −21 gql-checker/LICENSE
  54. +0 −4 gql-checker/MANIFEST.in
  55. +0 −29 gql-checker/README.rst
  56. +0 −18 gql-checker/gql_checker/__about__.py
  57. +0 −118 gql-checker/gql_checker/__init__.py
  58. +0 −50 gql-checker/gql_checker/flake8_linter.py
  59. +0 −36 gql-checker/gql_checker/pylama_linter.py
  60. +0 −330 gql-checker/gql_checker/stdlib_list.py
  61. +0 −2 gql-checker/setup.cfg
  62. +0 −64 gql-checker/setup.py
  63. 0 gql-checker/tests/__init__.py
  64. +0 −1 gql-checker/tests/introspection_schema.json
  65. +0 −7 gql-checker/tests/test_cases/bad_query.py
  66. +0 −3 gql-checker/tests/test_cases/noqa.py
  67. +0 −3 gql-checker/tests/test_cases/syntax_error.py
  68. +0 −78 gql-checker/tests/test_cases/validation.py
  69. +0 −56 gql-checker/tests/test_flake8_linter.py
  70. +0 −50 gql-checker/tests/test_pylama_linter.py
  71. +0 −19 gql-checker/tests/utils.py
  72. +0 −38 gql-checker/tox.ini
  73. +4 −0 gql/__init__.py
  74. +1 −1 gql/__version__.py
  75. +42 −5 gql/cli.py
  76. +1,051 −429 gql/client.py
  77. +44 −14 gql/dsl.py
  78. +11 −12 gql/gql.py
  79. +124 −0 gql/graphql_request.py
  80. +247 −177 gql/transport/aiohttp.py
  81. +170 −0 gql/transport/aiohttp_websockets.py
  82. +2 −2 gql/transport/appsync_auth.py
  83. +30 −24 gql/transport/appsync_websockets.py
  84. +24 −9 gql/transport/async_transport.py
  85. +10 −0 gql/transport/common/__init__.py
  86. +3 −0 gql/transport/common/adapters/__init__.py
  87. +278 −0 gql/transport/common/adapters/aiohttp.py
  88. +68 −0 gql/transport/common/adapters/connection.py
  89. +156 −0 gql/transport/common/adapters/websockets.py
  90. +59 −0 gql/transport/common/aiohttp_closed_event.py
  91. +112 −199 gql/transport/{websockets_base.py → common/base.py}
  92. +76 −0 gql/transport/common/batch.py
  93. +58 −0 gql/transport/common/listener_queue.py
  94. +9 −1 gql/transport/exceptions.py
  95. +126 −0 gql/transport/file_upload.py
  96. +183 −76 gql/transport/httpx.py
  97. +44 −11 gql/transport/local_schema.py
  98. +43 −19 gql/transport/phoenix_channel_websockets.py
  99. +250 −117 gql/transport/requests.py
  100. +29 −4 gql/transport/transport.py
  101. +33 −449 gql/transport/websockets.py
  102. +511 −0 gql/transport/websockets_protocol.py
  103. +2 −0 gql/utilities/__init__.py
  104. +2 −5 gql/utilities/build_client_schema.py
  105. +18 −4 gql/utilities/get_introspection_query_ast.py
  106. +92 −0 gql/utilities/node_tree.py
  107. +9 −4 gql/utilities/parse_result.py
  108. +1 −1 gql/utilities/update_schema_enum.py
  109. +6 −2 gql/utilities/update_schema_scalars.py
  110. +1 −38 gql/utils.py
  111. +22 −0 pyproject.toml
  112. +0 −14 setup.cfg
  113. +28 −25 setup.py
  114. +364 −47 tests/conftest.py
  115. +10 −35 tests/custom_scalars/test_datetime.py
  116. +34 −22 tests/custom_scalars/test_enum_colors.py
  117. +8 −8 tests/custom_scalars/test_json.py
  118. +130 −73 tests/custom_scalars/test_money.py
  119. +2 −3 tests/custom_scalars/test_parse_results.py
  120. +1 −1 tests/fixtures/aws/fake_credentials.py
  121. +1 −1 tests/fixtures/aws/fake_request.py
  122. +1 −1 tests/fixtures/aws/fake_session.py
  123. +3 −3 tests/fixtures/aws/fake_signer.py
  124. +385 −0 tests/fixtures/vcr_cassettes/queries_batch.yaml
  125. +79 −0 tests/regressions/issue_447_dsl_missing_directives/test_dsl_directives.py
  126. +2 −1 tests/starwars/fixtures.py
  127. +7 −3 tests/starwars/schema.py
  128. +311 −25 tests/starwars/test_dsl.py
  129. +5 −4 tests/starwars/test_introspection.py
  130. +49 −9 tests/starwars/test_parse_results.py
  131. +8 −8 tests/starwars/test_query.py
  132. +19 −7 tests/starwars/test_subscription.py
  133. +9 −5 tests/starwars/test_validation.py
  134. +666 −313 tests/test_aiohttp.py
  135. +523 −0 tests/test_aiohttp_batch.py
  136. +11 −14 tests/test_aiohttp_online.py
  137. +403 −0 tests/test_aiohttp_websocket_exceptions.py
  138. +276 −0 tests/test_aiohttp_websocket_graphqlws_exceptions.py
  139. +907 −0 tests/test_aiohttp_websocket_graphqlws_subscription.py
  140. +763 −0 tests/test_aiohttp_websocket_query.py
  141. +814 −0 tests/test_aiohttp_websocket_subscription.py
  142. +26 −19 tests/test_appsync_auth.py
  143. +6 −6 tests/test_appsync_http.py
  144. +46 −35 tests/test_appsync_websockets.py
  145. +21 −27 tests/test_async_client_validation.py
  146. +20 −3 tests/test_cli.py
  147. +75 −45 tests/test_client.py
  148. +238 −0 tests/test_graphql_request.py
  149. +46 −37 tests/test_graphqlws_exceptions.py
  150. +98 −75 tests/test_graphqlws_subscription.py
  151. +19 −24 tests/test_http_async_sync.py
  152. +348 −285 tests/test_httpx.py
  153. +326 −268 tests/test_httpx_async.py
  154. +436 −0 tests/test_httpx_batch.py
  155. +11 −14 tests/test_httpx_online.py
  156. +20 −0 tests/test_localhost_client.crt
  157. +24 −35 tests/test_phoenix_channel_exceptions.py
  158. +93 −12 tests/test_phoenix_channel_query.py
  159. +24 −30 tests/test_phoenix_channel_subscription.py
  160. +538 −265 tests/test_requests.py
  161. +678 −0 tests/test_requests_batch.py
  162. +8 −2 tests/test_transport.py
  163. +153 −0 tests/test_transport_batch.py
  164. +60 −44 tests/test_websocket_exceptions.py
  165. +29 −20 tests/test_websocket_online.py
  166. +142 −56 tests/test_websocket_query.py
  167. +62 −50 tests/test_websocket_subscription.py
  168. +100 −0 tests/test_websockets_adapter.py
  169. +12 −12 tox.ini
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ assignees: ''

**Common problems**
- 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
- 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)
- 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)
- 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

**Describe the bug**
22 changes: 12 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -7,20 +7,22 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Build wheel and source tarball
python-version: 3.12
- name: Install build dependencies
run: |
pip install wheel
python setup.py sdist bdist_wheel
python -m pip install --upgrade pip
pip install build wheel
- name: Build package
run: |
python -m build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.1.0
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
13 changes: 8 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Lint

permissions:
contents: read

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
46 changes: 28 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Tests

permissions:
contents: read

on: [push, pull_request]

jobs:
@@ -8,24 +11,24 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "pypy3.8"]
os: [ubuntu-20.04, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]
os: [ubuntu-24.04, windows-latest]
exclude:
- os: windows-latest
python-version: "3.7"
- os: windows-latest
python-version: "3.9"
- os: windows-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.11"
- os: windows-latest
python-version: "pypy3.8"
python-version: "3.13"
- os: windows-latest
python-version: "pypy3.10"

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
@@ -38,18 +41,18 @@ jobs:
TOXENV: ${{ matrix.toxenv }}

single_extra:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
dependency: ["aiohttp", "requests", "httpx", "websockets"]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies with only ${{ matrix.dependency }} extra dependency
run: |
python -m pip install --upgrade pip wheel
@@ -58,19 +61,26 @@ jobs:
run: pytest tests --${{ matrix.dependency }}-only

coverage:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

permissions:
contents: read
checks: write

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v4
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12
- name: Install test dependencies
run: |
python -m pip install --upgrade pip wheel
pip install -e.[test]
- name: Test with coverage
run: pytest --cov=gql --cov-report=xml --cov-report=term-missing tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -26,4 +26,3 @@ python:
path: .
extra_requirements:
- all
system_packages: true
6 changes: 2 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -6,18 +6,16 @@ include README.md
include CONTRIBUTING.md
include .readthedocs.yaml

include dev_requirements.txt
include Makefile

include tox.ini

include gql/py.typed

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

prune docs/_build
prune gql-checker

global-exclude *.py[co] __pycache__
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ tests_websockets:
pytest tests --websockets-only

check:
isort --recursive $(SRC_PYTHON)
isort $(SRC_PYTHON)
black $(SRC_PYTHON)
flake8 $(SRC_PYTHON)
mypy $(SRC_PYTHON)
57 changes: 50 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# GQL

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

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

@@ -37,9 +38,10 @@ The complete documentation for GQL can be found at
* AWS AppSync realtime protocol (experimental)
* 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
* Supports GraphQL queries, mutations and [subscriptions](https://gql.readthedocs.io/en/latest/usage/subscriptions.html)
* 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)
* 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)
* Supports [File uploads](https://gql.readthedocs.io/en/latest/usage/file_upload.html)
* Supports [Custom scalars / Enums](https://gql.readthedocs.io/en/latest/usage/custom_scalars_and_enums.html)
* Supports [Batching requests](https://gql.readthedocs.io/en/latest/advanced/batching_requests.html)
* [gql-cli script](https://gql.readthedocs.io/en/latest/gql-cli/intro.html) to execute GraphQL queries or download schemas from the command line
* [DSL module](https://gql.readthedocs.io/en/latest/advanced/dsl_module.html) to compose GraphQL queries dynamically

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

### Basic usage
### Sync usage

```python
from gql import gql, Client
from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport

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

# Create a GraphQL client using the defined transport
client = Client(transport=transport, fetch_schema_from_transport=True)
client = Client(transport=transport)

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

> **WARNING**: Please note that this basic example won't work if you have an asyncio event loop running. In some
> python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you. In that case you
> should use instead the [async usage example](https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage).
> should use instead the [async usage example](https://gql.readthedocs.io/en/latest/usage/async_usage.html#async-usage).
### Async usage

```python
import asyncio

from gql import Client, gql
from gql.transport.aiohttp import AIOHTTPTransport


async def main():

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

# Create a GraphQL client using the defined transport
client = Client(transport=transport)

# Provide a GraphQL query
query = gql(
"""
query getContinents {
continents {
code
name
}
}
"""
)

# Using `async with` on the client will start a connection on the transport
# and provide a `session` variable to execute queries on this connection
async with client as session:

# Execute the query
result = await session.execute(query)
print(result)


asyncio.run(main())
```

## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXOPTS ?= -n
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
13 changes: 12 additions & 1 deletion docs/advanced/async_permanent_session.rst
Original file line number Diff line number Diff line change
@@ -75,7 +75,6 @@ backoff decorator to the :code:`retry_execute` argument.
backoff.expo,
Exception,
max_tries=3,
giveup=lambda e: isinstance(e, TransportQueryError),
)
session = await client.connect_async(
reconnecting=True,
@@ -84,6 +83,18 @@ backoff decorator to the :code:`retry_execute` argument.
If you don't want any retry on the execute calls, you can disable the retries with :code:`retry_execute=False`

.. note::
If you want to retry even with :code:`TransportQueryError` exceptions,
then you need to make your own backoff decorator on your own method:

.. code-block:: python
@backoff.on_exception(backoff.expo,
Exception,
max_tries=3)
async def execute_with_retry(session, query):
return await session.execute(query)
Subscription retries
^^^^^^^^^^^^^^^^^^^^

Loading