A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I'm uploading video media via shopify graphql product api but the thumbnails are wrong (showing thumbnails of other videos). But after clicking play the correct video plays. I've tried setting the media thumbnail to null and empty string but that doesn't work also.
const generateStagedUploads = (productId, sourceURL, mediaType) => {
return `
mutation createProductMedia {
productCreateMedia(productId: "${productId}", media: [
{
originalSource: "${sourceURL}",
alt: "${productId}",
mediaContentType: ${mediaType}
}
]) {
media {
... fieldsForMediaTypes
mediaErrors {
code
details
message
}
}
product {
id
}
mediaUserErrors {
code
field
message
}
}
}
fragment fieldsForMediaTypes on Media {
alt
mediaContentType
preview {
image {
id
}
}
status
... on Video {
id
sources {
format
height
mimeType
url
width
}
}
}
`
}
const generateStagedUploadsVideoMuation = ({ video_name, video_size }) => {
return `
mutation generateStagedUploads {
stagedUploadsCreate(input: [
{
filename: "${video_name}",
mimeType: "video/mp4",
resource: VIDEO,
fileSize: "${video_size}"
},
])
{
stagedTargets {
url
resourceUrl
parameters {
name
value
}
}
userErrors {
field, message
}
}
}
`
}
exports.set_media_thumbnail_to_empty_string = async (product_id, media_id, first_image_url) => {
await client.query({
data: {
"query": `mutation productUpdateMedia($media: [UpdateMediaInput!]!, $productId: ID!) {
productUpdateMedia(media: $media, productId: $productId) {
media {
alt
}
}
}`,
"variables": {
"productId": product_id,
"media": [
{
"previewImageSource": first_image_url,
"id": media_id
},
]
},
},
})
}