The id specified in productCreate is ignored.

The id specified in productCreate is ignored.

asamacat
Visitor
1 0 0

In the GraphQL Admin API, when I execute a query with an id in productCreate, the specified ID is not registered, but the ID numbered by shopify is registered.

 

The specified ID is the id of the ProductInput, the id of the ProductVariant, and
The API version is 2021-10.

 

The following is the query that I ran.

The id values are set so that there are no duplicates.
What was wrong with it?

 

 

 

mutation {
  productCreate( input: 
    {
      id:"gid://shopify/Product/7103618613439",
      title: "test product"
      variants:
      [{
          id: "gid://shopify/ProductVariant/41047365222586"
          title: "test variant"
      }]
    }
  ) {
    product {
      id
      variants(first:1) {
        edges {
          node {
            id
          }
        }
      }
    } userErrors { 
      message
    }
  }
} 

 

 

Here is the result

{
  "data": {
    "productCreate": {
      "product": {
        "id": "gid://shopify/Product/7113547645118",
        "variants": {
          "edges": [
            {
              "node": {
                "id": "gid://shopify/ProductVariant/41078505144510"
              }
            }
          ]
        }
      },
      "userErrors": []
    }
  }
}
     
Reply 1 (1)

Jason
Shopify Partner
11207 226 2319

You can't set the ID of your objects. IDs are unique across the platform, not just to the one shop so it's something that Shopify will continue to be the master record owner of.

 

If you need to set an ID perhaps you could look at storing that value somewhere else for cross referencing.

★ I jump on these forums in my free time to help and share some insights. Not looking to be hired, and not looking for work. http://freakdesign.com.au ★