feat: add createdAt to userKeys, tour participations

This commit is contained in:
MTG2000
2022-09-09 07:50:36 +03:00
parent f7d86633b3
commit 764c6b6622
3 changed files with 20 additions and 5 deletions

View File

@@ -171,9 +171,16 @@ const MyProfile = objectType({
t.nonNull.list.nonNull.field('walletsKeys', {
type: "WalletKey",
resolve: async (parent, _, context) => {
const userKeys = await prisma.user.findUnique({ where: { id: parent.id } }).userKeys();
return userKeys.map(k => ({ ...k, is_current: k.key === context.userPubKey }))
resolve: (parent, _, context) => {
return prisma.userKey.findMany({
where: {
user_id: parent.id,
},
orderBy: {
createdAt: "asc"
}
})
.then(keys => keys.map(k => ({ ...k, is_current: k.key === context.userPubKey })))
}
});
}
@@ -283,6 +290,7 @@ const WalletKey = objectType({
definition(t) {
t.nonNull.string('key');
t.nonNull.string('name');
t.nonNull.date('createdAt');
t.nonNull.boolean('is_current')
}
})