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!
This commit is contained in:
Matt Dunn-Rankin 2020-05-19 14:57:25 -07:00
parent b47392f17f
commit 94b05ad95b

View file

@ -25,7 +25,11 @@ function useOutfitState() {
const allItemIds = [...state.wornItemIds, ...state.closetedItemIds]; const allItemIds = [...state.wornItemIds, ...state.closetedItemIds];
const { loading, error, data } = useQuery( const { loading, error, data } = useQuery(
gql` gql`
query OutfitState($allItemIds: [ID!]!, $speciesId: ID!, $colorId: ID!) { query OutfitStateItems(
$allItemIds: [ID!]!
$speciesId: ID!
$colorId: ID!
) {
items(ids: $allItemIds) { items(ids: $allItemIds) {
# TODO: De-dupe this from SearchPanel? # TODO: De-dupe this from SearchPanel?
id id
@ -49,7 +53,10 @@ function useOutfitState() {
} }
${itemAppearanceFragment} ${itemAppearanceFragment}
`, `,
{ variables: { allItemIds, speciesId, colorId } } {
variables: { allItemIds, speciesId, colorId },
skip: allItemIds.length === 0,
}
); );
const items = (data && data.items) || []; const items = (data && data.items) || [];