Shopify/storefront-api-examples

node Query on ShopifyCheckout returns incorrect number of lineItems

Simba14 opened this issue · 0 comments

Steps to Produce:
An item is added successfully to an existing checkout on my 'product' page (the mutation checkoutLineItemsAdd is used for this.)

When I directly navigate to the 'Basket' page, the graphql query below is called, which returns the ShopifyCheckout. The data returned contains the incorrect number of lineItems aka the added item is not present.
Strangely though the totalPrice field has updated correctly (it does include the added item's price).

On a page refresh the correct number of items are fetched.

Any one encounter a similar issue / have any thoughts on what the issue might be?

const fetchBasketGraphqlQuery = graphql(gql`
  query FetchBasket($id: ID!) {
    basket: node(id: $id) {
      ... on ShopifyCheckout {
        id
        totalPrice
        webUrl
        lineItems(first: 10) {
          edges {
            node {
              id
              quantity
              title
              variant {
                id
                image {
                  altText
                  originalSrc
                }
                price
                title
              }
            }
          }
        }
      }
    }
  }
`, {
  skip: props => !props.checkoutId,
  options: props => {
    return ({
      variables: {
        id: props.checkoutId,
      },
    })
  },
})