Add createdAt and updatedAt to Outfit GQL

Not used in-app yet, but Dice wanted it for the Discord Neobot!
This commit is contained in:
Emi Matchu 2021-04-23 13:02:13 -07:00
parent fc6cb2dfdd
commit a0107aaf7b

View file

@ -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: {