From 94b05ad95bb7ed511274847f9a7c8799d41d9fb1 Mon Sep 17 00:00:00 2001 From: Matt Dunn-Rankin Date: Tue, 19 May 2020 14:57:25 -0700 Subject: [PATCH] skip OutfitStateItems query if there are no items Kinda surprised our cache redirect isn't good enough for this, but I guess Apollo can't differentiate between a confident empty list vs an uncertain empty list! --- src/app/useOutfitState.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/app/useOutfitState.js b/src/app/useOutfitState.js index c5df2b4..25554b5 100644 --- a/src/app/useOutfitState.js +++ b/src/app/useOutfitState.js @@ -25,7 +25,11 @@ function useOutfitState() { const allItemIds = [...state.wornItemIds, ...state.closetedItemIds]; const { loading, error, data } = useQuery( gql` - query OutfitState($allItemIds: [ID!]!, $speciesId: ID!, $colorId: ID!) { + query OutfitStateItems( + $allItemIds: [ID!]! + $speciesId: ID! + $colorId: ID! + ) { items(ids: $allItemIds) { # TODO: De-dupe this from SearchPanel? id @@ -49,7 +53,10 @@ function useOutfitState() { } ${itemAppearanceFragment} `, - { variables: { allItemIds, speciesId, colorId } } + { + variables: { allItemIds, speciesId, colorId }, + skip: allItemIds.length === 0, + } ); const items = (data && data.items) || [];