A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
When i send a request using GraphQL to Create Product Media, it created an media record with no image (image return nil)
My x-request-id is: 894a6cae-a2b4-4202-96ca-c94d01f49d47
and my query is below:
mutation {
productCreateMedia(productId: "gid://shopify/Product/8116906590494", media: [ { alt: "", originalSource: "https://shopify-staged-uploads.storage.googleapis.com/tmp/69855510814/products/8f3e3f2c-ee85-44be-a226-dbdc6bcbeaf4/soba-noodles-sauce-garnishes-japanese-260nw-1100194787.jpg", mediaContentType: IMAGE } ]) {
media {
... on MediaImage {
id
originalSource
mediaContentType
}
}
mediaUserErrors {
code
field
message
}
}
}
The image file you referenced does not exist. You got a null back because I believe you are incorrectly using the ... on MediaImage command.
But other than that if the file existed it should be created on the product.
Try this:
mutation {
productCreateMedia(productId: "gid://shopify/Product/8116906590494", media: [ { alt: "", originalSource: "https://cdn.esawebb.org/archives/images/screen/weic2216b.jpg", mediaContentType: IMAGE } ]) {
media {
alt
mediaContentType
status
}
mediaUserErrors {
code
field
message
}
}
}
The response I got (with my own product id of course)
{
"data": {
"productCreateMedia": {
"media": [
{
"alt": "",
"mediaContentType": "IMAGE",
"status": "UPLOADED"
}
],
"mediaUserErrors": []
}
},
Cheers,
Gary