inventory Item Updatemutation
mutation
2024-10latest
Requires write
access scope. Also: The user must have a permission to update an inventory item.
Updates an inventory item.
Arguments
The ID of the inventory item to update.
The input fields that update an
inventory
.Item
Was this section helpful?
InventoryItemUpdatePayload returns
The inventory item that was updated.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: inventoryItemUpdate
Query Reference for MUTATION: inventoryItemUpdate
"mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {\n inventoryItemUpdate(id: $id, input: $input) {\n inventoryItem {\n # InventoryItem fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: inventoryItemUpdate
"{\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"input\": {\n \"cost\": \"29.99\",\n \"countryCodeOfOrigin\": \"AC\",\n \"countryHarmonizedSystemCodes\": [\n {\n \"countryCode\": \"AC\",\n \"harmonizedSystemCode\": \"<your-harmonizedSystemCode>\"\n }\n ],\n \"harmonizedSystemCode\": \"<your-harmonizedSystemCode>\",\n \"measurement\": {\n \"weight\": {\n \"unit\": \"GRAMS\",\n \"value\": 1.1\n }\n },\n \"provinceCodeOfOrigin\": \"<your-provinceCodeOfOrigin>\",\n \"requiresShipping\": true,\n \"sku\": \"<your-sku>\",\n \"tracked\": true\n }\n}"
Schema Reference for MUTATION: inventoryItemUpdate
"input InventoryItemInput {\n cost: Decimal\n countryCodeOfOrigin: CountryCode\n countryHarmonizedSystemCodes: [CountryHarmonizedSystemCodeInput!]\n harmonizedSystemCode: String\n measurement: InventoryItemMeasurementInput\n provinceCodeOfOrigin: String\n requiresShipping: Boolean\n sku: String\n tracked: Boolean\n}\n\ninput CountryHarmonizedSystemCodeInput {\n countryCode: CountryCode!\n harmonizedSystemCode: String!\n}\n\ninput InventoryItemMeasurementInput {\n weight: WeightInput\n}\n"
Display Examples for MUTATION: inventoryItemUpdate
[ { "example": { "type_name": "inventoryitemupdate", "title": "Updating an inventory item", "query_string": "mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {\n inventoryItemUpdate(id: $id, input: $input) {\n inventoryItem {\n id\n unitCost {\n amount\n }\n tracked\n countryCodeOfOrigin\n provinceCodeOfOrigin\n harmonizedSystemCode\n countryHarmonizedSystemCodes(first: 1) {\n edges {\n node {\n harmonizedSystemCode\n countryCode\n }\n }\n }\n }\n userErrors {\n message\n }\n }\n}", "variables": { "id": "gid://shopify/InventoryItem/43729076", "input": { "cost": 145.89, "tracked": false, "countryCodeOfOrigin": "US", "provinceCodeOfOrigin": "OR", "harmonizedSystemCode": "621710", "countryHarmonizedSystemCodes": [ { "harmonizedSystemCode": "6217109510", "countryCode": "CA" } ] } }, "response": { "data": { "inventoryItemUpdate": { "inventoryItem": { "id": "gid://shopify/InventoryItem/43729076", "unitCost": { "amount": "145.89" }, "tracked": false, "countryCodeOfOrigin": "US", "provinceCodeOfOrigin": "OR", "harmonizedSystemCode": "621710", "countryHarmonizedSystemCodes": { "edges": [ { "node": { "harmonizedSystemCode": "6217109510", "countryCode": "CA" } } ] } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2024-07", "maximum_api_version": "unstable", "location": "/components/inventory/test/unit/graph_api/admin/mutations/inventory_item_update_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) { inventoryItemUpdate(id: $id, input: $input) { inventoryItem { id unitCost { amount } tracked countryCodeOfOrigin provinceCodeOfOrigin harmonizedSystemCode countryHarmonizedSystemCodes(first: 1) { edges { node { harmonizedSystemCode countryCode } } } } userErrors { message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/InventoryItem/43729076\",\n \"input\": {\n \"cost\": 145.89,\n \"tracked\": false,\n \"countryCodeOfOrigin\": \"US\",\n \"provinceCodeOfOrigin\": \"OR\",\n \"harmonizedSystemCode\": \"621710\",\n \"countryHarmonizedSystemCodes\": [\n {\n \"harmonizedSystemCode\": \"6217109510\",\n \"countryCode\": \"CA\"\n }\n ]\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {\n inventoryItemUpdate(id: $id, input: $input) {\n inventoryItem {\n id\n unitCost {\n amount\n }\n tracked\n countryCodeOfOrigin\n provinceCodeOfOrigin\n harmonizedSystemCode\n countryHarmonizedSystemCodes(first: 1) {\n edges {\n node {\n harmonizedSystemCode\n countryCode\n }\n }\n }\n }\n userErrors {\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/InventoryItem/43729076\",\n \"input\": {\n \"cost\": 145.89,\n \"tracked\": false,\n \"countryCodeOfOrigin\": \"US\",\n \"provinceCodeOfOrigin\": \"OR\",\n \"harmonizedSystemCode\": \"621710\",\n \"countryHarmonizedSystemCodes\": [\n {\n \"harmonizedSystemCode\": \"6217109510\",\n \"countryCode\": \"CA\"\n }\n ]\n }\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {\n inventoryItemUpdate(id: $id, input: $input) {\n inventoryItem {\n id\n unitCost {\n amount\n }\n tracked\n countryCodeOfOrigin\n provinceCodeOfOrigin\n harmonizedSystemCode\n countryHarmonizedSystemCodes(first: 1) {\n edges {\n node {\n harmonizedSystemCode\n countryCode\n }\n }\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/InventoryItem/43729076\",\n \"input\": {\n \"cost\": 145.89,\n \"tracked\": false,\n \"countryCodeOfOrigin\": \"US\",\n \"provinceCodeOfOrigin\": \"OR\",\n \"harmonizedSystemCode\": \"621710\",\n \"countryHarmonizedSystemCodes\": [{\"harmonizedSystemCode\"=>\"6217109510\", \"countryCode\"=>\"CA\"}]\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {\n inventoryItemUpdate(id: $id, input: $input) {\n inventoryItem {\n id\n unitCost {\n amount\n }\n tracked\n countryCodeOfOrigin\n provinceCodeOfOrigin\n harmonizedSystemCode\n countryHarmonizedSystemCodes(first: 1) {\n edges {\n node {\n harmonizedSystemCode\n countryCode\n }\n }\n }\n }\n userErrors {\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/InventoryItem/43729076\",\n \"input\": {\n \"cost\": 145.89,\n \"tracked\": false,\n \"countryCodeOfOrigin\": \"US\",\n \"provinceCodeOfOrigin\": \"OR\",\n \"harmonizedSystemCode\": \"621710\",\n \"countryHarmonizedSystemCodes\": [\n {\n \"harmonizedSystemCode\": \"6217109510\",\n \"countryCode\": \"CA\"\n }\n ]\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {\n inventoryItemUpdate(id: $id, input: $input) {\n inventoryItem {\n id\n unitCost {\n amount\n }\n tracked\n countryCodeOfOrigin\n provinceCodeOfOrigin\n harmonizedSystemCode\n countryHarmonizedSystemCodes(first: 1) {\n edges {\n node {\n harmonizedSystemCode\n countryCode\n }\n }\n }\n }\n userErrors {\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/InventoryItem/43729076\",\n \"input\" => [\n \"cost\" => 145.89,\n \"tracked\" => false,\n \"countryCodeOfOrigin\" => \"US\",\n \"provinceCodeOfOrigin\" => \"OR\",\n \"harmonizedSystemCode\" => \"621710\",\n \"countryHarmonizedSystemCodes\" => [{\"harmonizedSystemCode\"=>\"6217109510\", \"countryCode\"=>\"CA\"}],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the inventory item to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/InventoryItem/43729076\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The input fields that update an\n[`inventoryItem`](https://shopify.dev/api/admin-graphql/latest/queries/inventoryitem).", "type": { "kind": "INPUT_OBJECT", "name": "InventoryItemInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "InventoryItemInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"cost\":145.89,\"tracked\":false,\"countryCodeOfOrigin\":\"US\",\"provinceCodeOfOrigin\":\"OR\",\"harmonizedSystemCode\":\"621710\",\"countryHarmonizedSystemCodes\":[{\"harmonizedSystemCode\":\"6217109510\",\"countryCode\":\"CA\"}]}", "typeKind": "MUTATION" } ] } ]