Skip to content

Commit

Permalink
Fix notification subscription mutation cache
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Jan 8, 2025
1 parent 963b2d8 commit 05ec26d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/src/graphql/mutations/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useMutation, MutationHookOptions } from "@apollo/client";

import MeGql from "../queries/Me.gql";
import {
ActivateNewUserMutation,
ActivateNewUserMutationVariables,
Expand Down Expand Up @@ -136,6 +137,7 @@ import {
UpdateNotificationSubscriptionsMutation,
UpdateNotificationSubscriptionsMutationVariables,
MarkNotificationsReadDocument,
MeQuery,
} from "../types";

export const useActivateUser = (
Expand Down Expand Up @@ -444,8 +446,11 @@ export const useUpdateNotificationSubscriptions = (
useMutation(UpdateNotificationSubscriptionsDocument, {
update(cache, { data }) {
if (data?.updateNotificationSubscriptions) {
const user = cache.read<MeQuery>({ query: MeGql, optimistic: false });

cache.evict({
fieldName: "queryNotifications",
id: cache.identify({ __typename: "User", id: user?.me?.id }),
fieldName: "notification_subscriptions",
});
}
},
Expand Down

0 comments on commit 05ec26d

Please sign in to comment.