Creating products and informations in GraphQL through N8N

Creating products and informations in GraphQL through N8N

flavio_ns
Tourist
16 0 1

Hey folks, i'm trying to migrate from API Rest to GraphQL in N8N because i got an automation workflow where i receive some products through JSON information, BUT in REST i can create the product with price, name, stock available and other stuff, on GraphQL the only options i can create is Title, HTML description, tags and vendor... but i need to place the price, stock, some products we sell by specific units (like 10$/100ml) and etcetera.

The only thing that worked was creating the product:

mutation CreateProduct {
  productCreate(product: {
    title: "Purple LED Light",
    descriptionHtml: "<p>Description on HTML</p>",
    productType: "Lights",
    vendor: "MXLED",
    tags: ["LED", "PURPLE"],
    metafields: [
    {
    }]
  }) {
    product {
      id
      title
      vendor
      tags
    }
    shop {
      id
    }
    userErrors {
      field
      message
    }
  }
}

PS: More than 90/95% of products are unique, so if there's another type, it's another product, so I'm not going to create a product with several variants, there may be a few exceptions.

Reply 1 (1)

Liviu_Ungureanu
Shopify Partner
19 0 2

Have a look at the productSet mutation: it allows you to add variants with price and more.

 

https://shopify.dev/docs/api/admin-graphql/latest/mutations/productSet