Open nabijaczleweli opened 1 year ago
https://github.com/99designs/gqlgen/blob/213a085b954945eeaa1fc87f0fedef2c07fe14c1/docs/content/reference/file-upload.md says:
It implements the following spec jaydenseric/graphql-multipart-request-spec, that defines an interoperable multipart form field structure for GraphQL requests, used by various file upload client implementations.
https://github.com/jaydenseric/graphql-multipart-request-spec/tree/28d6448b75eaf86498cdb6f18d71a1953a1ca444#batching demonstrates:
curl localhost:3001/graphql \ -F operations='[{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }, { "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id } }", "variables": { "files": [null, null] } }]' \ -F map='{ "0": ["0.variables.file"], "1": ["1.variables.files.0"], "2": ["1.variables.files.1"] }' \ -F 0=@a.txt \ -F 1=@b.txt \ -F 2=@c.txt
This allows one to trivially adapt the https://github.com/99designs/gqlgen/tree/c287a7b0b40cdd8c94077ed54fff257fe383e796/_examples/fileupload#curl-request sample from:
curl localhost:8087/query \ -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } }' \ -F map='{ "0": [ "variables.file" ] }' \ -F 0=@a
to:
curl localhost:8087/query \ -F operations='[ { "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } }, { "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } } ]' \ -F map='{ "0": [ "0.variables.file" ], "1": [ "1.variables.file" ] }' \ -F 0=@a \ -F 1=@b
and get
{ "errors": [ { "message": "operations form field could not be decoded" } ], "data": null }
Hm.
One may try to objectify operations= to:
curl localhost:8087/query \ -F operations='{ "0": { "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } }, "1": { "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id, name, content } }", "variables": { "file": null } } }' \ -F map='{ "0": [ "0.variables.file" ], "1": [ "1.variables.file" ] }' \ -F 0=@a \ -F 1=@b
{ "errors": [ { "message": "invalid operations paths for key 0" } ], "data": null }
Huh. By all accounts I don't see why this wouldn't work.
As I see it this is either one issue: don't purport to support gq-mp-r-s; or two: accept arrays, parse the paths.
gqlgen 3087cf3a9830f80d01f508cf49d55e2370f60a19, Debian go 2:1.19~1~bpo11+1; fell out of downstream https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3C20221031231236.c7waexidmb7n7g2x%40tarta.nabijaczleweli.xyz%3E
I'm also attempting to get this working, so would appreciate any input.
https://github.com/99designs/gqlgen/blob/213a085b954945eeaa1fc87f0fedef2c07fe14c1/docs/content/reference/file-upload.md says:
https://github.com/jaydenseric/graphql-multipart-request-spec/tree/28d6448b75eaf86498cdb6f18d71a1953a1ca444#batching demonstrates:
This allows one to trivially adapt the https://github.com/99designs/gqlgen/tree/c287a7b0b40cdd8c94077ed54fff257fe383e796/_examples/fileupload#curl-request sample from:
to:
and get
Hm.
One may try to objectify operations= to:
and get
Huh. By all accounts I don't see why this wouldn't work.
As I see it this is either one issue: don't purport to support gq-mp-r-s; or two: accept arrays, parse the paths.
gqlgen 3087cf3a9830f80d01f508cf49d55e2370f60a19, Debian go 2:1.19~1~bpo11+1; fell out of downstream https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3C20221031231236.c7waexidmb7n7g2x%40tarta.nabijaczleweli.xyz%3E