Rejects array -F operations=, but accepts objectified array, but rejects -F map= paths?
- Ngôn ngữ chính
- Go
- Star
- 10.8k
- Fork
- 1.3k
- Merge trung bình
- 2 ngày 36 phút
- Pull request đã merge (30 ngày)
- 26
Mô tả
says:
> It implements the following spec [jaydenseric/graphql-multipart-request-spec](https://github.com/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:
```sh
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:
```sh
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:
```sh
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
```json
{
"errors": [
{
"message": "operations form field could not be decoded"
}
],
"data": null
}
```
Hm.
One may try to objectify operations= to:
```sh
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
```
and get
```json
{
"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
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.