aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-07 02:46:25 -0700
committerFuwn <[email protected]>2024-10-07 02:46:25 -0700
commit444c496a212859accd992f2b5cb57e091cbaa7a8 (patch)
tree82d37b8178abb30038f8b6484dcef5300270b068
parentfix(graphql): wait for database update on badge mutation (diff)
downloaddue.moe-444c496a212859accd992f2b5cb57e091cbaa7a8.tar.xz
due.moe-444c496a212859accd992f2b5cb57e091cbaa7a8.zip
fix(graphql): return null for no user id access
-rw-r--r--src/graphql/user/resolvers.ts2
-rw-r--r--src/graphql/user/schema.graphql2
2 files changed, 3 insertions, 1 deletions
diff --git a/src/graphql/user/resolvers.ts b/src/graphql/user/resolvers.ts
index 2e1160bc..ebdba2a6 100644
--- a/src/graphql/user/resolvers.ts
+++ b/src/graphql/user/resolvers.ts
@@ -70,6 +70,8 @@ const authenticatedPreferencesOperation = async (
export const resolvers: WithIndex<Resolvers> = {
Query: {
User: async (_, args) => {
+ if (!args.id) return null;
+
return {
id: args.id,
badges: (await getUserBadges(args.id)) as Badge[],
diff --git a/src/graphql/user/schema.graphql b/src/graphql/user/schema.graphql
index 66d14ce0..b8217b5a 100644
--- a/src/graphql/user/schema.graphql
+++ b/src/graphql/user/schema.graphql
@@ -1,5 +1,5 @@
type Query {
- User(id: Int): User!
+ User(id: Int): User
}
type Mutation {