Hi!
I am developing a third-party application that uses the Shopify GraphQL API (version 2020.10) to add .mp4 videos to products. I have successfully completed the steps described in https://shopify.dev/api/examples/product-media (created an upload URL, uploaded the video and linked the video to a product). However, the following two issues appeared:
- The last mutation, which links the video to the product does not return any sources (empty array) or originalSource (it is null) on Media nodes of type Video. However, the video is present on the actual product in the Shopify store. The mutation is presented below:
const LINK_MEDIA_TO_PRODUCT = gql`
mutation productCreateMedia($productId: ID!, $media: [CreateMediaInput!]!) {
productCreateMedia(productId: $productId, media: $media) {
media {
...fieldsForMediaTypes
}
mediaUserErrors {
code
field
message
}
product {
id
}
}
}
fragment fieldsForMediaTypes on Media {
alt
mediaContentType
preview {
image {
id
}
}
status
... on Video {
id
sources {
format
height
mimeType
url
width
}
originalSource {
format
height
mimeType
url
width
}
}
}
`;
- The second problem is that one of the functionalities of the application is to manage the videos on the products, so the application must play the videos and display them in a list. However, all the links that are present in the sources list on the Video node are CDN links. (as tested with the Shopify GraphQL application installed on the store) The documentation states that the links for Video and 3D objects stored on the CDN expire, but it does not state how long it takes for the videos to expire. In this context, how can I ensure that the users of the application can always play the videos and see a thumbnail for them? How long does it take for a video to expire?
Thank you!