python-graphql-client icon indicating copy to clipboard operation
python-graphql-client copied to clipboard

Support file uploads

Open sreerajkksd opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe. Client need to upload files to the graphql backed server. Describe the solution you'd like Server implement graphql file upload using some custom libraries (eg: using the spec mentioned here and implementation here).

Describe alternatives you've considered Doing it natively using requests library is an option, but there are some overheads and graphql client library is the best place to put it. Looks like not a lot client libraries (available for python) out there support file uploads.

Additional context

The implementation would be something like this:

Inputs: query: str, variables: dict, operationName: str, files: BinaryIO

Generate the following fields:

operations:{"query": "mutation uploadFiles($files: [Upload]) {uploadFiles(files: $files) { success }", "variables": { "files": [null,null] }}
map:{ "0": ["variables.files.0"], "1": ["variables.files.1"]}

And files can be kept in a key value pair where key is the stringified index (eg: "0" or "1") and value is the opened file.

sreerajkksd avatar Sep 18 '20 04:09 sreerajkksd

+1 for Upload support

jmauersberger avatar Apr 04 '22 09:04 jmauersberger

interesting ...

firdavsDev avatar Nov 10 '22 11:11 firdavsDev