GraphQl ProductCreate with Images

Highlighted
Shopify Partner
23 0 0

Hi, 

    I am trying to add a new product with images using GraphQL. and  using Polaris DropZone for getting the images and passing the ProductInput variable to ProductCreate mutation after setting images src to the the a local file url. But it's not working. Any idea how can I attach the images dropped using DropZone to the images src property. I even tried to replace the local url with the Base64Data of the image but still not working. I would highly appreciate your help.

 

Code for ProductInput Variable:

                        const productInput = {
                            title: title,
                            images: files.map( (file, index) => (
                              {
                                altText: file.name,
                                src: window.URL.createObjectURL(file)
                              }
                              )),
                            bodyHtml: bodyHtml,
                          };
0 Likes