Rejects array -F operations=, but accepts objectified array, but rejects -F map= paths?
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
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
贡献指南
调研方向
这个 issue 涉及文件上传的 multipart 请求解析,参考 graphql-multipart-request-spec。查看文件上传处理代码,可能在解码 'operations' 和 'map' 字段的 handler 附近。针对 fileupload 示例测试提供的 curl 命令,以复现错误。检查类似 '0.variables.file' 的路径与 'variables.file' 的解析方式有何不同。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go, graphql
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100