我正在使用 Ariadne 创建一个 python GraphQL 服务器,并且我有以下突变来上传文件:
type Mutation {
uploadUserAvatar(file: Upload!): Boolean!
}
以下 curl 命令用于上传图片:
curl http://localhost:8080/ \
-F operations='{ "query":"mutation ($file: Upload!) { uploadUserAvatar(file: $file) }","variables": { "file": null} }' \
-F map='{ "0": ["variables.file"] }' \
-F 0=@image.jpeg
上面的命令可以完美地将图像上传到端点。
但是,我需要将用户 ID 与图像一起传递,如下所示:
type Mutation {
uploadUserAvatar(userid: String!, file: Upload!): Boolean!
}
我正在努力获得正确的 curl 命令来上传带有userid
.
我尝试了下面的命令
curl http://localhost:8080/ \
-F operations='{ "query":"mutation ($userid: String!, $file: Upload!) { uploadUserAvatar(userid: $userid, file: $file) }","variables": { "file": null, "userid": null } }' \
-F map='{ "0": ["variables.file"], "1": ["variables.userid"] }' \
-F 0=@etiqueta_LG.jpeg \
-F 1='abc1234'
但我收到了这个回复File data was missing for entry key '1' (https://github.com/jaydenseric/graphql-multipart-request-spec).
如何调用我的 GraphQL 端点传递userid
和image
for upload ?