Skip to content

Commit

Permalink
Merge pull request #5 from MiSArch/adapted-inventory-count-query
Browse files Browse the repository at this point in the history
Adapted inventory count query
  • Loading branch information
legendofa authored Apr 23, 2024
2 parents 3cf62b8 + 222c93a commit 6db75b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 1 addition & 3 deletions queries/get_unreserved_product_item_counts.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ query GetUnreservedProductItemCounts($representations: [_Any!]!) {
__typename
... on ProductVariant {
id,
productItems(filter: { inventoryStatus: IN_STORAGE }) {
totalCount
}
inventoryCount,
}
}
}
6 changes: 2 additions & 4 deletions src/mutation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,11 @@ fn build_stock_counts_by_product_variant_from_response_data(
.entities
.into_iter()
.map(|maybe_product_variant_enum| {
let message = format!("Response data of `check_product_variant_availability` query could not be parsed, `{:?}` is `None`", maybe_product_variant_enum);
let message = format!("Response data of `check_product_variant_availability` query could not be parsed, `maybe_product_variant_enum` is `None`");
let product_variant_enum = maybe_product_variant_enum.ok_or(Error::new(message))?;
let stock_counts_by_product_variant: Result<(Uuid, u64)> = match product_variant_enum {
get_unreserved_product_item_counts::GetUnreservedProductItemCountsEntities::ProductVariant(product_variant) => {
let message = format!("Response data of `check_product_variant_availability` query could not be parsed, `{:?}` is `None`", product_variant.product_items);
let product_items = product_variant.product_items.ok_or(Error::new(message))?;
let stock_count = u64::try_from(product_items.total_count)?;
let stock_count = u64::try_from(product_variant.inventory_count)?;
Ok(
(
product_variant.id,
Expand Down

0 comments on commit 6db75b0

Please sign in to comment.