aboutsummaryrefslogtreecommitdiff
path: root/src/graphql/user
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphql/user')
-rw-r--r--src/graphql/user/resolvers.ts17
-rw-r--r--src/graphql/user/schema.graphql1
2 files changed, 13 insertions, 5 deletions
diff --git a/src/graphql/user/resolvers.ts b/src/graphql/user/resolvers.ts
index ebdba2a6..9bccbd6b 100644
--- a/src/graphql/user/resolvers.ts
+++ b/src/graphql/user/resolvers.ts
@@ -43,10 +43,13 @@ const authenticatedBadgesOperation = async (
await operation(identity, authorised);
+ const badges = await getUserBadges(identity.id)
+
return {
id: identity.id,
- badges: await getUserBadges(identity.id),
- preferences: {}
+ badges,
+ preferences: {},
+ badgesCount: badges.length
}
};
@@ -63,7 +66,8 @@ const authenticatedPreferencesOperation = async (
return {
id: identity.id,
badges: [] as Badge[],
- preferences: await operation(identity, authorised)
+ preferences: await operation(identity, authorised),
+ badgesCount: 0
}
};
@@ -72,10 +76,13 @@ export const resolvers: WithIndex<Resolvers> = {
User: async (_, args) => {
if (!args.id) return null;
+ const badges = (await getUserBadges(args.id))
+
return {
id: args.id,
- badges: (await getUserBadges(args.id)) as Badge[],
- preferences: await getUserPreferences(args.id)
+ badges,
+ preferences: await getUserPreferences(args.id),
+ badgesCount: badges.length
};
}
},
diff --git a/src/graphql/user/schema.graphql b/src/graphql/user/schema.graphql
index b8217b5a..f0ac3081 100644
--- a/src/graphql/user/schema.graphql
+++ b/src/graphql/user/schema.graphql
@@ -32,6 +32,7 @@ type User {
id: Int!
badges: [Badge!]!
preferences: Preferences
+ badgesCount: Int!
}
type Badge {