productCreateMedia mutation not returning preview image

arjun_rajkumar
Excursionist
19 1 0

hey!

 

I am using the query to create an image

productCreateMedia(productId: $productId, media: $media) {
  media {
    alt
    mediaContentType
    status

     preview {
      image {
         id
      }
    }
  }
  product {
    id
  }
}

 

 

This creates the image and returns the following 

{"media"=>[{"__typename"=>"MediaImage", "alt"=>"", "mediaContentType"=>"IMAGE", "preview"=>{"image"=>nil}, "status"=>"UPLOADED", "mediaErrors"=>[]}], "product"=>{"id"=>"gid://shopify/Product/5311831539871"}, "mediaUserErrors"=>[]}

 

Is there someway I can access the newly created image id? the id is actually available under preview but it is returning nil currently for some reason.. 

 

wondering how to fix this. 

 

thanks

Arjun

 

0 Likes
arjun_rajkumar
Excursionist
19 1 0

I think this is happening because the image is uploaded but not processed yet. 

 

FAILED

Preview image processing has failed.

PROCESSING

Preview image is being processed.

READY

Preview image is ready to be displayed.

UPLOADED

Preview image is uploaded but not yet processed.

 

I am getting back the status as uploaded, but without the image id. 

just wondering how I could wait for this to be processed so that I can retrieve the image id also with this request. 

 

 

0 Likes