@@ -118,6 +118,97 @@ def test_code():
118118 await run_sync_test (server , test_code )
119119
120120
121+ @pytest .mark .aiohttp
122+ @pytest .mark .asyncio
123+ async def test_httpx_async_batch_query_with_extensions (aiohttp_server ):
124+ from aiohttp import web
125+
126+ from gql .transport .httpx import HTTPXAsyncTransport
127+
128+ async def handler (request ):
129+ body = await request .json ()
130+ assert isinstance (body , list )
131+ assert "extensions" in body [0 ]
132+ assert body [0 ]["extensions" ] == {
133+ "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
134+ }
135+ return web .Response (
136+ text = query1_server_answer_list ,
137+ content_type = "application/json" ,
138+ )
139+
140+ app = web .Application ()
141+ app .router .add_route ("POST" , "/" , handler )
142+ server = await aiohttp_server (app )
143+
144+ url = str (server .make_url ("/" ))
145+
146+ transport = HTTPXAsyncTransport (url = url , timeout = 10 )
147+
148+ async with Client (transport = transport ) as session :
149+
150+ query = [
151+ GraphQLRequest (
152+ query1_str ,
153+ extensions = {
154+ "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
155+ },
156+ )
157+ ]
158+
159+ results = await session .execute_batch (query )
160+
161+ continents = results [0 ]["continents" ]
162+ assert continents [0 ]["code" ] == "AF"
163+
164+
165+ @pytest .mark .aiohttp
166+ @pytest .mark .asyncio
167+ async def test_httpx_sync_batch_query_with_extensions (aiohttp_server , run_sync_test ):
168+ from aiohttp import web
169+
170+ from gql .transport .httpx import HTTPXTransport
171+
172+ async def handler (request ):
173+ body = await request .json ()
174+ assert isinstance (body , list )
175+ assert "extensions" in body [0 ]
176+ assert body [0 ]["extensions" ] == {
177+ "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
178+ }
179+ return web .Response (
180+ text = query1_server_answer_list ,
181+ content_type = "application/json" ,
182+ )
183+
184+ app = web .Application ()
185+ app .router .add_route ("POST" , "/" , handler )
186+ server = await aiohttp_server (app )
187+
188+ url = str (server .make_url ("/" ))
189+
190+ transport = HTTPXTransport (url = url , timeout = 10 )
191+
192+ def test_code ():
193+ with Client (transport = transport ) as session :
194+
195+ query = [
196+ GraphQLRequest (
197+ query1_str ,
198+ extensions = {
199+ "persistedQuery" : {"version" : 1 , "sha256Hash" : "abc123" }
200+ },
201+ )
202+ ]
203+
204+ results = session .execute_batch (query )
205+
206+ continents = results [0 ]["continents" ]
207+ assert continents [0 ]["code" ] == "AF"
208+
209+ await run_sync_test (server , test_code )
210+
211+
121212@pytest .mark .aiohttp
122213@pytest .mark .asyncio
123214async def test_httpx_async_batch_query_without_session (aiohttp_server , run_sync_test ):
0 commit comments