diff --git a/src/app/WardrobePage/useOutfitState.js b/src/app/WardrobePage/useOutfitState.js index efb622f..2248874 100644 --- a/src/app/WardrobePage/useOutfitState.js +++ b/src/app/WardrobePage/useOutfitState.js @@ -62,7 +62,7 @@ function useOutfitState() { } ); - const items = (data && data.items) || []; + const items = data?.items || []; const itemsById = {}; for (const item of items) { itemsById[item.id] = item; diff --git a/src/app/apolloClient.js b/src/app/apolloClient.js index f1fb727..2e2b065 100644 --- a/src/app/apolloClient.js +++ b/src/app/apolloClient.js @@ -8,8 +8,11 @@ const typePolicies = { // when you remove an item from your outfit, or add an item from search, // Apollo knows it already has the data it needs and doesn't need to ask // the server again! - items: (_, { args, toReference }) => - args.ids.map((id) => toReference({ __typename: "Item", id })), + items: (_, { args, toReference }) => { + return args.ids.map((id) => + toReference({ __typename: "Item", id }, true) + ); + }, // Teach Apollo how to serve `petAppearance` queries from the cache. That // way, when you switch pet poses, Apollo knows it already has the @@ -17,7 +20,7 @@ const typePolicies = { petAppearance: (_, { args, toReference }) => { const { speciesId, colorId, pose } = args; const id = `${speciesId}-${colorId}-${pose}`; - return toReference({ __typename: "PetAppearance", id }); + return toReference({ __typename: "PetAppearance", id }, true); }, }, },