@@ -1824,3 +1824,108 @@ async def handler(request):
1824
1824
assert africa ["code" ] == "AF"
1825
1825
1826
1826
await connector .close ()
1827
+
1828
+
1829
+ @pytest .mark .asyncio
1830
+ async def test_aiohttp_deprecation_warning_using_document_node_execute (aiohttp_server ):
1831
+ from aiohttp import web
1832
+
1833
+ from gql .transport .aiohttp import AIOHTTPTransport
1834
+
1835
+ async def handler (request ):
1836
+ return web .Response (
1837
+ text = query1_server_answer ,
1838
+ content_type = "application/json" ,
1839
+ )
1840
+
1841
+ app = web .Application ()
1842
+ app .router .add_route ("POST" , "/" , handler )
1843
+ server = await aiohttp_server (app )
1844
+
1845
+ url = server .make_url ("/" )
1846
+
1847
+ transport = AIOHTTPTransport (url = url , timeout = 10 )
1848
+
1849
+ async with Client (transport = transport ) as session :
1850
+
1851
+ query = gql (query1_str )
1852
+
1853
+ with pytest .warns (
1854
+ DeprecationWarning ,
1855
+ match = "Using a DocumentNode is deprecated" ,
1856
+ ):
1857
+ result = await session .execute (query .document )
1858
+
1859
+ continents = result ["continents" ]
1860
+
1861
+ africa = continents [0 ]
1862
+
1863
+ assert africa ["code" ] == "AF"
1864
+
1865
+
1866
+ @pytest .mark .asyncio
1867
+ async def test_aiohttp_deprecation_warning_execute_variable_values (aiohttp_server ):
1868
+ from aiohttp import web
1869
+
1870
+ from gql .transport .aiohttp import AIOHTTPTransport
1871
+
1872
+ async def handler (request ):
1873
+ return web .Response (text = query2_server_answer , content_type = "application/json" )
1874
+
1875
+ app = web .Application ()
1876
+ app .router .add_route ("POST" , "/" , handler )
1877
+ server = await aiohttp_server (app )
1878
+
1879
+ url = server .make_url ("/" )
1880
+
1881
+ transport = AIOHTTPTransport (url = url , timeout = 10 )
1882
+
1883
+ async with Client (transport = transport ) as session :
1884
+
1885
+ params = {"code" : "EU" }
1886
+
1887
+ query = gql (query2_str )
1888
+
1889
+ with pytest .warns (
1890
+ DeprecationWarning ,
1891
+ match = (
1892
+ "Using variable_values and operation_name arguments of "
1893
+ "execute and subscribe methods is deprecated"
1894
+ ),
1895
+ ):
1896
+ result = await session .execute (
1897
+ query , variable_values = params , operation_name = "getEurope"
1898
+ )
1899
+
1900
+ continent = result ["continent" ]
1901
+
1902
+ assert continent ["name" ] == "Europe"
1903
+
1904
+
1905
+ @pytest .mark .asyncio
1906
+ async def test_aiohttp_type_error_execute (aiohttp_server ):
1907
+ from aiohttp import web
1908
+
1909
+ from gql .transport .aiohttp import AIOHTTPTransport
1910
+
1911
+ async def handler (request ):
1912
+ return web .Response (text = query2_server_answer , content_type = "application/json" )
1913
+
1914
+ app = web .Application ()
1915
+ app .router .add_route ("POST" , "/" , handler )
1916
+ server = await aiohttp_server (app )
1917
+
1918
+ url = server .make_url ("/" )
1919
+
1920
+ transport = AIOHTTPTransport (url = url , timeout = 10 )
1921
+
1922
+ async with Client (transport = transport ) as session :
1923
+
1924
+ params = {"code" : "EU" }
1925
+
1926
+ query = gql (query2_str )
1927
+
1928
+ with pytest .raises (TypeError ) as exc_info :
1929
+ await session .execute ("qmlsdkfj" )
1930
+
1931
+ assert "request should be a GraphQLRequest object" in str (exc_info .value )
0 commit comments