FAQ: How to find inventory change logs via GraphQL

This topic aims to foster knowledge in our community, mainly regarding the use of GraphQL, and to provide an example of a query that can help retrieve important information related to inventory.

It’s worth noting that we have a learn on the subject at the following link:

As well as the following documentation on Developers:

Where can you find GraphQL in the VTEX Admin?

If your account already has the app installed, it can be found by navigating to “Store Settings”“STOREFRONT”“GraphQL IDE”

In this case, since the example proposed here is a Query tied to your store’s inventory, the selected app should be: vtex.inventory-graphql@0.20.0

To check the inventory change logs for a given SKU, simply use the query below, replacing {{skuID}} with the ID of the SKU for which you want to retrieve the change logs, and {{warehouseId}} with the ID of the desired warehouse, which can be found at the following link:

https://{{accountName}}.myvtex.com/admin/shipping-strategy/beta/warehouses

It’s also worth noting that you need to replace the {{accountName}} field with your VTEX account name.

{
	productHistory(
    sku: "{{skuId}}"
    warehouseId: "{{warehouseId}}"
    accountName: "{{accountName}}"){
  				sku
				quantity
				changelogHistory{
						user
						date
						quantityBefore
						quantityAfter
						unlimitedBefore
						unlimitedAfter
				}
			}
}

If you still have any questions on the topic, feel free to ask here! :smiling_face:

Karina Mota
Partner Field Software Engineer | VTEX

4 Likes