Need help getting a product to upload using graphql

Highlighted
New Member
2 0 0

Hello, I am creating an app that takes in information from the user and creates a product from that information. I am using react and graphql. I got it working with just the product title, vendor and type, but it doesn't work when I try to add a price or any other variant information. Any suggestions as to why this might not be working is much appreciated. 

 

const New_Product = gql`
          mutation {
            productCreate(input: {
              title: "${PartManufacturer} ${PartMake} ${ModelName}", 
              descriptionHtml: "",
              productType: "${PartType}", 
              vendor: "${this.state.Vendor}",

              variants: [{
                price: "${this.state.Price}",
                compareAtPrice: "${this.state.CompareAtPrice}",
                sku: "${this.state.SKU}",
                barcode: "${this.state.Barcode}",
                weight: "${this.state.Weight}"
               }]
              
            }) 
            
            {
              userErrors {
                field,
                message
              }
            }
          }
        `;

          return (
            <Mutation mutation={New_Product}>
              {(createProduct, { data }) => (
                <div>
                  
                    <button type="submit" onClick={createProduct}>Create Product</button>
                  
                </div>
              )}
            </Mutation>
          );
        };
0 Likes