Handle non-existant outfits better

Gotta remember to check the validity of IDs earlier than that lol!
This commit is contained in:
Emi Matchu 2021-04-16 19:18:28 -07:00
parent 9e2f9eab16
commit e3ac9d06e5
2 changed files with 13 additions and 3 deletions

View file

@ -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 };
},
},
};

View file

@ -106,7 +106,6 @@ const resolvers = {
items: (...args) => resolvers.Pet.wornItems(...args),
},
Query: {
outfit: (_, { id }) => ({ id }),
petOnNeopetsDotCom: async (
_,
{ petName },