@@ -15,7 +15,7 @@ In order to upload a single file, you need to:
1515
1616* set the file as a variable value in the mutation
1717* create a :class: `FileVar <gql.FileVar> ` object with your file path
18- * provide the `FileVar ` instance to the `variable_values ` argument of ` execute `
18+ * provide the `FileVar ` instance to the `variable_values ` attribute of your query
1919* set the `upload_files ` argument to True
2020
2121.. code-block :: python
@@ -37,11 +37,9 @@ In order to upload a single file, you need to:
3737 }
3838 ''' )
3939
40- params = {" file" : FileVar(" YOUR_FILE_PATH" )}
40+ query.variable_values = {" file" : FileVar(" YOUR_FILE_PATH" )}
4141
42- result = client.execute(
43- query, variable_values = params, upload_files = True
44- )
42+ result = client.execute(query, upload_files = True )
4543
4644 Setting the content-type
4745^^^^^^^^^^^^^^^^^^^^^^^^
@@ -97,11 +95,9 @@ It is also possible to upload multiple files using a list.
9795 f1 = FileVar(" YOUR_FILE_PATH_1" )
9896 f2 = FileVar(" YOUR_FILE_PATH_2" )
9997
100- params = {" files" : [f1, f2]}
98+ query.variable_values = {" files" : [f1, f2]}
10199
102- result = client.execute(
103- query, variable_values = params, upload_files = True
104- )
100+ result = client.execute(query, upload_files = True )
105101
106102
107103 Streaming
@@ -150,11 +146,9 @@ setting the `streaming` argument of :class:`FileVar <gql.FileVar>` to `True`
150146 streaming = True ,
151147 )
152148
153- params = {" file" : f1}
149+ query.variable_values = {" file" : f1}
154150
155- result = client.execute(
156- query, variable_values = params, upload_files = True
157- )
151+ result = client.execute(query, upload_files = True )
158152
159153 Another option is to use an async generator to provide parts of the file.
160154
@@ -172,11 +166,9 @@ to read the files in chunks and create this asynchronous generator.
172166 yield chunk
173167
174168 f1 = FileVar(file_sender(file_name = ' YOUR_FILE_PATH' ))
175- params = {" file" : f1}
169+ query.variable_values = {" file" : f1}
176170
177- result = client.execute(
178- query, variable_values = params, upload_files = True
179- )
171+ result = client.execute(query, upload_files = True )
180172
181173 Streaming downloaded files
182174^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -193,7 +185,7 @@ In order to do that, you need to:
193185
194186* get the response from an aiohttp request and then get the StreamReader instance
195187 from `resp.content `
196- * provide the StreamReader instance to the `variable_values ` argument of ` execute `
188+ * provide the StreamReader instance to the `variable_values ` attribute of your query
197189
198190Example:
199191
@@ -204,7 +196,7 @@ Example:
204196 async with http_client.get(' YOUR_DOWNLOAD_URL' ) as resp:
205197
206198 # We now have a StreamReader instance in resp.content
207- # and we provide it to the variable_values argument of execute
199+ # and we provide it to the variable_values attribute of the query
208200
209201 transport = AIOHTTPTransport(url = ' YOUR_GRAPHQL_URL' )
210202
@@ -218,8 +210,6 @@ Example:
218210 }
219211 ''' )
220212
221- params = {" file" : FileVar(resp.content)}
213+ query.variable_values = {" file" : FileVar(resp.content)}
222214
223- result = client.execute(
224- query, variable_values = params, upload_files = True
225- )
215+ result = client.execute(query, upload_files = True )
0 commit comments