aboutsummaryrefslogtreecommitdiff
path: root/src/graphql/user
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphql/user')
-rw-r--r--src/graphql/user/index.ts4
-rw-r--r--src/graphql/user/resolvers.ts14
-rw-r--r--src/graphql/user/schema.graphql22
3 files changed, 40 insertions, 0 deletions
diff --git a/src/graphql/user/index.ts b/src/graphql/user/index.ts
new file mode 100644
index 00000000..925a7ece
--- /dev/null
+++ b/src/graphql/user/index.ts
@@ -0,0 +1,4 @@
+import typeDefs from './schema.graphql?raw';
+import { resolvers } from './resolvers';
+
+export default { typeDefs, resolvers };
diff --git a/src/graphql/user/resolvers.ts b/src/graphql/user/resolvers.ts
new file mode 100644
index 00000000..a18358be
--- /dev/null
+++ b/src/graphql/user/resolvers.ts
@@ -0,0 +1,14 @@
+import { getUserBadges } from '$lib/Database/SB/User/badges';
+import type { WithIndex } from '../$types';
+import type { Resolvers, Badge } from './$types';
+
+export const resolvers: WithIndex<Resolvers> = {
+ Query: {
+ User: async (_, args /* , _context */) => {
+ 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
new file mode 100644
index 00000000..d4360a39
--- /dev/null
+++ b/src/graphql/user/schema.graphql
@@ -0,0 +1,22 @@
+type Query {
+ User(id: Int!): User
+}
+
+type User {
+ id: Int!
+ badges: [Badge]
+}
+
+type Badge {
+ post: String
+ image: String
+ description: String
+ id: Int
+ time: String
+ category: String
+ hidden: Boolean
+ source: String
+ designer: String
+ shadow_hidden: Boolean
+ click_count: Int
+}