Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL mutation productChangeStatus

GraphQL mutation productChangeStatus

Lawson_Thalmann
Shopify Partner
84 0 69

I'm using this mutation to try to archive products in bulk. However, I can't even get it to accept one. What am I doing wrong here? See query and response below. This ID is most definitely in my product catalogue so I'm not sure what it doesn't like about it. 

 

mutation productChangeStatus($productId: ID!, $status: ProductStatus!) {
  productChangeStatus(productId: $productId, status: $status) {
    product {
      hasOutOfStockVariants
    }
    userErrors {
      field
      message
    }
  }
}
QUERY VARIABLES:

{
  "productId": 6597997559942,
  "status": "ARCHIVED"
}

 

Response:

 

{
  "errors": [
    {
      "message": "Variable $productId of type ID! was provided invalid value",
      "locations": [
        {
          "line": 1,
          "column": 30
        }
      ],
      "extensions": {
        "value": 6597997559942,
        "problems": [
          {
            "path": [],
            "explanation": "Invalid global id '6597997559942'",
            "message": "Invalid global id '6597997559942'"
          }
        ]
      }
    }
  ]
}
Reply 1 (1)

mikerowave
Shopify Staff (Retired)
22 3 2

Hi @Lawson_Thalmann!

The productId is of type ID (or global ID) and so it is expecting the following format:
gid://shopify/Product/6597997559942

Mike M (mikerowave) | API Support @ Shopify 
 - Was my reply helpful? Click Like to let me know!
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit shopify.dev or the Shopify Web Design and Development Blog