diff options
| author | Fuwn <[email protected]> | 2024-10-06 05:04:30 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-06 05:04:30 -0700 |
| commit | 2c7149546582e58fc7421ad68869b16a64b5f4ad (patch) | |
| tree | 06e7b44115eca71b6bc54d640f48d0a17916f56e /src/graphql | |
| parent | feat(user): use preferences graphl api (diff) | |
| download | due.moe-2c7149546582e58fc7421ad68869b16a64b5f4ad.tar.xz due.moe-2c7149546582e58fc7421ad68869b16a64b5f4ad.zip | |
feat(user): live update for mutations
Diffstat (limited to 'src/graphql')
| -rw-r--r-- | src/graphql/user/resolvers.ts | 21 | ||||
| -rw-r--r-- | src/graphql/user/schema.graphql | 18 |
2 files changed, 22 insertions, 17 deletions
diff --git a/src/graphql/user/resolvers.ts b/src/graphql/user/resolvers.ts index 66e3f1a2..3521f1a2 100644 --- a/src/graphql/user/resolvers.ts +++ b/src/graphql/user/resolvers.ts @@ -56,7 +56,11 @@ const authenticatedPreferencesOperation = async ( const authorised = authorisedJson.includes(identity.id); - return operation(identity, authorised) as Promise<UserPreferences> + return { + id: identity.id, + badges: [] as Badge[], + preferences: operation(identity, authorised) as Promise<UserPreferences> + } }; export const resolvers: WithIndex<Resolvers> = { @@ -136,36 +140,37 @@ export const resolvers: WithIndex<Resolvers> = { await authenticatedPreferencesOperation( context as Context, async (identity) => await toggleHideMissingBadges(identity.id) - ) as UserPreferences, + ), toggleHideAWCBadges: async (_, _args, context) => await authenticatedPreferencesOperation( context as Context, async (identity) => await toggleHideAWCBadges(identity.id) - ) as UserPreferences, + ), setBadgeWallCSS: async (_, args, context) => await authenticatedPreferencesOperation( context as Context, async (identity) => await setCSS(identity.id, args.css) - ) as UserPreferences, + ), togglePinnedBadgeWallCategory: async (_, args, context) => await authenticatedPreferencesOperation( context as Context, async (identity) => await togglePinnedBadgeWallCategory(identity.id, args.category) - ) as UserPreferences, + ), setPinnedBadgeWallCategories: async (_, args, context) => await authenticatedPreferencesOperation( context as Context, async (identity) => await setPinnedBadgeWallCategories(identity.id, args.categories) - ) as UserPreferences, + ), setBiography: async (_, args, context) => await authenticatedPreferencesOperation( context as Context, async (identity) => await setBiography(identity.id, args.biography.slice(0, 3000)) - ) as UserPreferences, + ) + , togglePinnedHololiveStream: async (_, args, context) => await authenticatedPreferencesOperation( context as Context, async (identity) => await toggleHololiveStreamPinning(identity.id, args.stream) - ) as UserPreferences, + ), } }; diff --git a/src/graphql/user/schema.graphql b/src/graphql/user/schema.graphql index 7c910015..b615a995 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 { @@ -19,18 +19,18 @@ type Mutation { ): [Badge]! deleteBadge(id: Int!): [Badge]! pruneUserBadges: [Badge]! - toggleHideMissingBadges: Preferences - toggleHideAWCBadges: Preferences - setBadgeWallCSS(css: String!): Preferences - togglePinnedBadgeWallCategory(category: String!): Preferences - setPinnedBadgeWallCategories(categories: [String!]!): Preferences - setBiography(biography: String!): Preferences - togglePinnedHololiveStream(stream: String!): Preferences + 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]! + badges: [Badge!]! preferences: Preferences } |