Anchor to inventoryAdjustQuantityinventory
inventoryAdjustQuantity
mutationDeprecated
Requires access scope. Also: The user must have a permission to adjusts an inventory quantity.
Adjusts the inventory by a certain quantity. Use instead.
Anchor to Arguments
Arguments
- Anchor to inputinput•Inventory
Adjust requiredQuantity Input! Provides the input fields required to update an inventory level.
Was this section helpful?
Anchor to InventoryAdjustQuantityPayload returnsInventoryAdjustQuantityPayload returns
- Anchor to inventoryLevelinventory•
Level Represents the updated inventory quantity of an inventory item at a specific location.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Decrease the available inventory of an item at a location by 2
- Increase the available inventory of an item at a location by 3
- inventoryAdjustQuantity reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation AdjustInventoryQuantity($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
incoming
item {
id
sku
}
location {
id
name
}
}
}
}`,
{
variables: {
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
mutation AdjustInventoryQuantity($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
incoming
item {
id
sku
}
location {
id
name
}
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation AdjustInventoryQuantity($input: InventoryAdjustQuantityInput!) { inventoryAdjustQuantity(input: $input) { inventoryLevel { id quantities(names: [\"available\"]) { name quantity } incoming item { id sku } location { id name } } } }",
"variables": {
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
"availableDelta": -2
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation AdjustInventoryQuantity($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
incoming
item {
id
sku
}
location {
id
name
}
}
}
}`,
{
variables: {
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
"availableDelta": -2
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation AdjustInventoryQuantity($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
incoming
item {
id
sku
}
location {
id
name
}
}
}
}`,
"variables": {
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
"availableDelta": -2
}
},
},
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation AdjustInventoryQuantity($input: InventoryAdjustQuantityInput!) {
inventoryAdjustQuantity(input: $input) {
inventoryLevel {
id
quantities(names: ["available"]) {
name
quantity
}
incoming
item {
id
sku
}
location {
id
name
}
}
}
}
QUERY
variables = {
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
"availableDelta": -2
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"input": {
"inventoryLevelId": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
"availableDelta": -2
}
}
Response
JSON{
"inventoryAdjustQuantity": {
"inventoryLevel": {
"id": "gid://shopify/InventoryLevel/964427794?inventory_item_id=43729076",
"quantities": [
{
"name": "available",
"quantity": -1
}
],
"incoming": 0,
"item": {
"id": "gid://shopify/InventoryItem/43729076",
"sku": "draft-151"
},
"location": {
"id": "gid://shopify/Location/124656943",
"name": "Shipping Origin"
}
}
}
}