From a0107aaf7b0d031c9469d5fd03289d557513b6a2 Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 23 Apr 2021 13:02:13 -0700 Subject: [PATCH] Add createdAt and updatedAt to Outfit GQL Not used in-app yet, but Dice wanted it for the Discord Neobot! --- src/server/types/Outfit.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/server/types/Outfit.js b/src/server/types/Outfit.js index 2c11232f..251081f3 100644 --- a/src/server/types/Outfit.js +++ b/src/server/types/Outfit.js @@ -10,6 +10,12 @@ const typeDefs = gql` closetedItems: [Item!]! creator: User + # When this outfit was created. ISO 8601 string. + createdAt: String! + + # When this outfit was last updated. ISO 8601 string. + updatedAt: String! + # This is a convenience field: you could query this from the combination of # petAppearance and wornItems, but this gets you it in one shot! itemAppearances: [ItemAppearance!]! @@ -89,6 +95,14 @@ const resolvers = { return { id: outfit.userId }; }, + createdAt: async ({ id }, _, { outfitLoader }) => { + const outfit = await outfitLoader.load(id); + return outfit.createdAt.toISOString(); + }, + updatedAt: async ({ id }, _, { outfitLoader }) => { + const outfit = await outfitLoader.load(id); + return outfit.updatedAt.toISOString(); + }, }, Query: {