aboutsummaryrefslogtreecommitdiff
path: root/src/graphql
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphql')
-rw-r--r--src/graphql/anime/resolvers.ts32
-rw-r--r--src/graphql/anime/schema.graphql30
-rw-r--r--src/graphql/user/resolvers.ts30
-rw-r--r--src/graphql/user/schema.graphql78
4 files changed, 89 insertions, 81 deletions
diff --git a/src/graphql/anime/resolvers.ts b/src/graphql/anime/resolvers.ts
index 7d04082d..5f49b364 100644
--- a/src/graphql/anime/resolvers.ts
+++ b/src/graphql/anime/resolvers.ts
@@ -2,21 +2,21 @@ import type { WithIndex } from '../$types';
import type { Resolvers } from './$types';
export const resolvers: WithIndex<Resolvers> = {
- Query: {
- Anime: async (_, args) => {
- const timezone = args.timezone || 'Asia/Tokyo';
+ Query: {
+ Anime: async (_, args) => {
+ const timezone = args.timezone || 'Asia/Tokyo';
- return {
- subtitles: {
- timezone,
- schedule: Object.fromEntries(
- Object.entries(
- (await (await fetch(`https://subsplease.org/api/?f=schedule&tz=${timezone}`)).json())
- .schedule
- ).map(([key, value]) => [key.toLowerCase(), value])
- )
- }
- };
- }
- }
+ return {
+ subtitles: {
+ timezone,
+ schedule: Object.fromEntries(
+ Object.entries(
+ (await (await fetch(`https://subsplease.org/api/?f=schedule&tz=${timezone}`)).json())
+ .schedule
+ ).map(([key, value]) => [key.toLowerCase(), value])
+ )
+ }
+ };
+ }
+ }
};
diff --git a/src/graphql/anime/schema.graphql b/src/graphql/anime/schema.graphql
index d5774966..a0415944 100644
--- a/src/graphql/anime/schema.graphql
+++ b/src/graphql/anime/schema.graphql
@@ -1,29 +1,29 @@
type Query {
- Anime(timezone: String): Anime!
+ Anime(timezone: String): Anime!
}
type Anime {
- subtitles: Subtitles
+ subtitles: Subtitles
}
type Subtitles {
- timezone: String
- schedule: SubtitleSchedule
+ timezone: String
+ schedule: SubtitleSchedule
}
type SubtitleSchedule {
- monday: [Subtitle]
- tuesday: [Subtitle]
- wednesday: [Subtitle]
- thursday: [Subtitle]
- friday: [Subtitle]
- saturday: [Subtitle]
- sunday: [Subtitle]
+ monday: [Subtitle]
+ tuesday: [Subtitle]
+ wednesday: [Subtitle]
+ thursday: [Subtitle]
+ friday: [Subtitle]
+ saturday: [Subtitle]
+ sunday: [Subtitle]
}
type Subtitle {
- title: String
- page: String
- image_url: String
- time: String
+ title: String
+ page: String
+ image_url: String
+ time: String
}
diff --git a/src/graphql/user/resolvers.ts b/src/graphql/user/resolvers.ts
index 9bccbd6b..4609108a 100644
--- a/src/graphql/user/resolvers.ts
+++ b/src/graphql/user/resolvers.ts
@@ -12,7 +12,17 @@ import type { WithIndex } from '../$types';
import type { Resolvers, Badge } from './$types';
import authorisedJson from '$lib/Data/Static/authorised.json';
import type { RequestEvent } from '@sveltejs/kit';
-import { getUserPreferences, setBiography, setCSS, setPinnedBadgeWallCategories, toggleHideAWCBadges, toggleHideMissingBadges, toggleHololiveStreamPinning, togglePinnedBadgeWallCategory, type UserPreferences } from '$lib/Database/SB/User/preferences';
+import {
+ getUserPreferences,
+ setBiography,
+ setCSS,
+ setPinnedBadgeWallCategories,
+ toggleHideAWCBadges,
+ toggleHideMissingBadges,
+ toggleHololiveStreamPinning,
+ togglePinnedBadgeWallCategory,
+ type UserPreferences
+} from '$lib/Database/SB/User/preferences';
type Context = RequestEvent<Partial<Record<string, string>>, string | null>;
@@ -43,14 +53,14 @@ const authenticatedBadgesOperation = async (
await operation(identity, authorised);
- const badges = await getUserBadges(identity.id)
+ const badges = await getUserBadges(identity.id);
return {
id: identity.id,
badges,
preferences: {},
badgesCount: badges.length
- }
+ };
};
const authenticatedPreferencesOperation = async (
@@ -68,7 +78,7 @@ const authenticatedPreferencesOperation = async (
badges: [] as Badge[],
preferences: await operation(identity, authorised),
badgesCount: 0
- }
+ };
};
export const resolvers: WithIndex<Resolvers> = {
@@ -76,7 +86,7 @@ export const resolvers: WithIndex<Resolvers> = {
User: async (_, args) => {
if (!args.id) return null;
- const badges = (await getUserBadges(args.id))
+ const badges = await getUserBadges(args.id);
return {
id: args.id,
@@ -95,8 +105,7 @@ export const resolvers: WithIndex<Resolvers> = {
shadowHideBadge: async (_, args, context) =>
await authenticatedBadgesOperation(
context,
- async () =>
- await setShadowHiddenBadge(args.id, args.state == null ? true : args.state)
+ async () => await setShadowHiddenBadge(args.id, args.state == null ? true : args.state)
),
hideBadge: async (_, args, context) =>
await authenticatedBadgesOperation(context, async (identity) => {
@@ -113,7 +122,7 @@ export const resolvers: WithIndex<Resolvers> = {
allBadges
.filter((badge) => badge.category === category)
.filter((badge) => badge.hidden).length >
- allBadges.filter((badge) => badge.category === category).length / 2
+ allBadges.filter((badge) => badge.category === category).length / 2
? false
: true
});
@@ -178,12 +187,11 @@ export const resolvers: WithIndex<Resolvers> = {
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await setBiography(identity.id, args.biography.slice(0, 3000))
- )
- ,
+ ),
togglePinnedHololiveStream: async (_, args, context) =>
await authenticatedPreferencesOperation(
context as Context,
async (identity) => await toggleHololiveStreamPinning(identity.id, args.stream)
- ),
+ )
}
};
diff --git a/src/graphql/user/schema.graphql b/src/graphql/user/schema.graphql
index f0ac3081..193b5daf 100644
--- a/src/graphql/user/schema.graphql
+++ b/src/graphql/user/schema.graphql
@@ -1,52 +1,52 @@
type Query {
- User(id: Int): User
+ User(id: Int): User
}
type Mutation {
- shadowHideBadges(userId: Int!): User!
- shadowHideBadge(id: Int!, state: Boolean): User!
- hideBadge(category: String): User!
- updateBadge(
- id: Int
- post: String
- image: String
- description: String
- time: String
- category: String
- hidden: Boolean
- source: String
- designer: String
- ): User!
- deleteBadge(id: Int!): User!
- pruneUserBadges: User!
- toggleHideMissingBadges: User!
- toggleHideAWCBadges: User!
- setBadgeWallCSS(css: String!): User!
- togglePinnedBadgeWallCategory(category: String!): User!
- setPinnedBadgeWallCategories(categories: [String!]!): User!
- setBiography(biography: String!): User!
- togglePinnedHololiveStream(stream: String!): User!
+ shadowHideBadges(userId: Int!): User!
+ shadowHideBadge(id: Int!, state: Boolean): User!
+ hideBadge(category: String): User!
+ updateBadge(
+ id: Int
+ post: String
+ image: String
+ description: String
+ time: String
+ category: String
+ hidden: Boolean
+ source: String
+ designer: String
+ ): User!
+ deleteBadge(id: Int!): User!
+ pruneUserBadges: User!
+ toggleHideMissingBadges: User!
+ toggleHideAWCBadges: User!
+ setBadgeWallCSS(css: String!): User!
+ togglePinnedBadgeWallCategory(category: String!): User!
+ setPinnedBadgeWallCategories(categories: [String!]!): User!
+ setBiography(biography: String!): User!
+ togglePinnedHololiveStream(stream: String!): User!
}
type User {
- id: Int!
- badges: [Badge!]!
- preferences: Preferences
- badgesCount: Int!
+ id: Int!
+ badges: [Badge!]!
+ preferences: Preferences
+ badgesCount: Int!
}
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!
+ post: String!
+ image: String!
+ description: String
+ id: Int!
+ time: String!
+ category: String
+ hidden: Boolean!
+ source: String
+ designer: String
+ shadow_hidden: Boolean!
+ click_count: Int!
}
type Preferences {