我已经能够制作一个脚本来保存一个文件使用新的filecrecreate,但当我试图删除一个文件与fileDelete,我似乎不能得到正确的ID。
mutation fileDelete($fileIds: [ID!]!) {
fileDelete(fileIds: $fileIds) {
userErrors {
field
message
}
deletedFileIds
}
}
我通过我的上一个图像的ID: "gid://shopify/ImageSource/20805776113730",用一个新的私有应用程序密钥调用(应该使用v2021-10)
如果有人能让这个突变起作用,我会很感激的。
Shopify的回应:
{
"data": {
"fileDelete": null
},
"errors": [{
"message": "invalid id",
"locations": [{
"line": 3,
"column": 4
}],
"path": ["fileDelete"]
}],
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 1,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 999,
"restoreRate": 50
}
}
}
}
发送的内容如下:
{
"query": "mutation fileDelete($fileIds: [ID!]!) {rntttfileDelete(fileIds: $fileIds) {rnttt userErrors {rnttttfieldrnttttmessagernttt }rnttt deletedFileIdsrnttt}rntt }",
"variables": {
"fileIds": "gid://shopify/ImageSource/20825330909250"
}
}
您需要发送ImageMedia ID:
{
"fileIds": "gid://shopify/MediaImage/20835931816073"
}
要获得该ID,您需要像这样发送请求:
{
files(first: 99, reverse:true){
edges{
cursor
node{
... on MediaImage {
id
mimeType
image {
originalSrc
}
}
__typename
createdAt
fileStatus
preview{
image{
altText
id
transformedSrc
originalSrc
}
status
}
}
}
}
}
反应:
{
"data": {
"files": {
"edges": [
{
"cursor": "xxxxxx",
"node": {
"id": "gid://shopify/MediaImage/xxxx",
"mimeType": "image/png",
"image": {
"originalSrc": "xxxx"
},
"__typename": "MediaImage",
"createdAt": "2021-10-21T17:39:58Z",
"fileStatus": "READY",
"preview": {
"image": {
"altText": "xxxx",
"id": "gid://shopify/ImageSource/xxxx",
"transformedSrc": "xxxx",
"originalSrc": "xxxx"
},
"status": "READY"
}
}
},
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 398,
"actualQueryCost": 18,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 982,
"restoreRate": 50.0
}
}
}
}