Using custom location_id while creating new product via Shopify Admin GraphQL API

Hi,

I am working on an app that’s imports and updates my Shopify Store Products from another source. While creating, I realized that i need to set my location_id property to update my product’s stocks , also i have multiple locations in my shop.Shared code below;

mutation {
  productCreate(
    input: {
      handle: "handle"
      bodyHtml: "bodyHtml"
      descriptionHtml: "descriptionHtml"
      tags: "tags, tags,tags"
      title: "title"
      vendor: "vendor"
      options: ["Size", "Color"]
      variants: [
        {
          price: "111"
          weight: 1
          sku: "4444444"
          options: ["S", "Rainbow"]
          inventoryQuantities: [
            { availableQuantity: 66, locationId: 65888846010 }
          ]
        }
      ]
      published: true
    }
  ) {
    product {
      id
    }
    userErrors {
      field
      message
    }
  }
}

without “inventoryQuantities” property under “variants” , code work perfectly, creates my new product and returns productid as response. When i add “inventoryQuantities” in mutation , returns

Invalid global id '65888846010' 

I just followed Shopify’s GraphQL API Guide and used “locationId” from one of my Shopify Store Locations

Thank you in advance for your help.

Hi @omermdincer

I think the ID might be in the wrong format there. Instead of 65888846010 can you please try “gid://shopify/Location/65888846010” - with the quotation marks. That should register as a valid location ID. Hope this helps!

Hi @csam ,

YES,YES,YES , IT WORKED !

Thank you so much for your support, I am such a newbie at GraphQL queries, but as said at song , Rome wasn’t built in a day :slightly_smiling_face:

King Regards