File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33Extensions
44----------
55
6+ Request extensions
7+ ^^^^^^^^^^^^^^^^^^
8+
9+ The `GraphQL over HTTP spec <https://github.com/graphql/graphql-over-http >`_
10+ defines an optional :code: `extensions ` field on requests. This is sent as a
11+ top-level key in the request payload alongside :code: `query `, :code: `variables `,
12+ and :code: `operationName `.
13+
14+ You can use this to pass protocol extensions such as
15+ `persisted queries <https://www.apollographql.com/docs/apollo-server/performance/apq/ >`_:
16+
17+ .. code-block :: python
18+
19+ from gql import Client, GraphQLRequest
20+ from gql.transport.aiohttp import AIOHTTPTransport
21+
22+ transport = AIOHTTPTransport(url = " https://example.com/graphql" )
23+
24+ async with Client(transport = transport) as session:
25+
26+ request = GraphQLRequest(
27+ " query { viewer { name } }" ,
28+ extensions = {
29+ " persistedQuery" : {
30+ " version" : 1 ,
31+ " sha256Hash" : " abc123..." ,
32+ }
33+ },
34+ )
35+
36+ result = await session.execute(request)
37+
38+ Response extensions
39+ ^^^^^^^^^^^^^^^^^^^
40+
641When you execute (or subscribe) GraphQL requests, the server will send
742responses which may have 3 fields:
843
You can’t perform that action at this time.
0 commit comments