Skip to content

Commit c000c51

Browse files
committed
Add extensions documentation
1 parent 9bafd7f commit c000c51

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

docs/usage/extensions.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. _extensions:
2+
3+
Extensions
4+
----------
5+
6+
When you execute (or subscribe) GraphQL requests, the server will send
7+
responses which may have 3 fields:
8+
9+
- data: the serialized response from the backend
10+
- errors: a list of potential errors
11+
- extensions: an optional field for additional data
12+
13+
If there are errors in the response, then the
14+
:code:`execute` or :code:`subscribe` methods will
15+
raise a :code:`TransportQueryError`.
16+
17+
If no errors are present, then only the data from the response is returned by default.
18+
19+
.. code-block:: python
20+
21+
result = client.execute(query)
22+
# result is here the content of the data field
23+
24+
If you need to receive the extensions data too, then you can run the
25+
:code:`execute` or :code:`subscribe` methods with :code:`get_execution_result=True`.
26+
27+
In that case, the full execution result is returned and you can have access
28+
to the extensions field
29+
30+
.. code-block:: python
31+
32+
result = client.execute(query, get_execution_result=True)
33+
# result is here an ExecutionResult instance
34+
35+
# result.data is the content of the data field
36+
# result.extensions is the content of the extensions field

docs/usage/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Usage
1111
headers
1212
file_upload
1313
custom_scalars_and_enums
14+
extensions

0 commit comments

Comments
 (0)