在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):jaydenseric/graphql-multipart-request-spec开源软件地址(OpenSource Url):https://github.com/jaydenseric/graphql-multipart-request-spec开源编程语言(OpenSource Language):开源软件介绍(OpenSource Introduction):GraphQL multipart request specificationAn interoperable multipart form field structure for GraphQL requests, used by various file upload client/server implementations. It’s possible to implement:
Multipart form field structureAn “operations object” is an Apollo GraphQL POST request (or array of requests if batching). An “operations path” is an So operations can be resolved while the files are still uploading, the fields are ordered:
ExamplesSingle fileOperations{
query: `
mutation($file: Upload!) {
singleUpload(file: $file) {
id
}
}
`,
variables: {
file: File // a.txt
}
} cURL requestcurl localhost:3001/graphql \
-F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }' \
-F map='{ "0": ["variables.file"] }' \
-F [email protected] Request payload
File listOperations{
query: `
mutation($files: [Upload!]!) {
multipleUpload(files: $files) {
id
}
}
`,
variables: {
files: [
File, // b.txt
File // c.txt
]
}
} cURL requestcurl localhost:3001/graphql \
-F operations='{ "query": "mutation($files: [Upload!]!) { multipleUpload(files: $files) { id } }", "variables": { "files": [null, null] } }' \
-F map='{ "0": ["variables.files.0"], "1": ["variables.files.1"] }' \
-F [email protected] \
-F [email protected] Request payload
BatchingOperations;[
{
query: `
mutation($file: Upload!) {
singleUpload(file: $file) {
id
}
}
`,
variables: {
file: File // a.txt
}
},
{
query: `
mutation($files: [Upload!]!) {
multipleUpload(files: $files) {
id
}
}
`,
variables: {
files: [
File, // b.txt
File // c.txt
]
}
}
] cURL requestcurl 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 [email protected] \
-F [email protected] \
-F [email protected] Request payload
ImplementationsPull requests adding either experimental or mature implementations to these lists are welcome! Client
Server
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论