From e3ac9d06e53d71d466e4a49bc4e2b4fb800e9085 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 16 Apr 2021 19:18:28 -0700 Subject: [PATCH] Handle non-existant outfits better Gotta remember to check the validity of IDs earlier than that lol! --- src/server/types/Outfit.js | 15 +++++++++++++-- src/server/types/Pet.js | 1 - 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/server/types/Outfit.js b/src/server/types/Outfit.js index ba2b00f..cb01d6b 100644 --- a/src/server/types/Outfit.js +++ b/src/server/types/Outfit.js @@ -70,11 +70,22 @@ const resolvers = { }, creator: async ({ id }, _, { outfitLoader }) => { const outfit = await outfitLoader.load(id); - return outfit.userId ? { id: outfit.userId } : null; + if (!outfit.userId) { + return null; + } + + return { id: outfit.userId }; }, }, Query: { - outfit: (_, { id }) => ({ id }), + outfit: async (_, { id }, { outfitLoader }) => { + const outfit = await outfitLoader.load(id); + if (!outfit) { + return null; + } + + return { id }; + }, }, }; diff --git a/src/server/types/Pet.js b/src/server/types/Pet.js index e2baa97..90dd528 100644 --- a/src/server/types/Pet.js +++ b/src/server/types/Pet.js @@ -106,7 +106,6 @@ const resolvers = { items: (...args) => resolvers.Pet.wornItems(...args), }, Query: { - outfit: (_, { id }) => ({ id }), petOnNeopetsDotCom: async ( _, { petName },