Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I am trying to query inventory items at a specific location using the shopify_api gem. If I just put a location ID into the query it works but when trying to pass it as a variable, not so much... any help would be appreciated.
def query_using_location_ids
client.parse <<-'GRAPHQL'
{
query inventoryItemsAtLocation($locationId: ID!) {
inventoryItems(first:10){
pageInfo{
hasNextPage
hasPreviousPage
}
edges{
node{
id
legacyResourceId
inventoryLevel(locationId: $locationId){
id
available
incoming
item{
id
legacyResourceId
sku
variant{
id
legacyResourceId
price
product{
description
}
}
unitCost{
amount
currencyCode
}
}
}
}
}
}
}
}
GRAPHQL
end
def client
@Client ||= ShopifyAPI::GraphQL.client
end
client.query(query_using_location_ids, variables: {locationId: id}).original_hash["data"]["inventoryItems"]
id passed is the global ID of the location