1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-11-21 23:00:50 +03:00

WIP my account page

This commit is contained in:
Quentin Gliech
2023-04-26 19:25:18 +02:00
parent 415d06f209
commit f62d045b8c
5 changed files with 239 additions and 65 deletions

View File

@@ -16,8 +16,34 @@ import { createClient, fetchExchange } from "@urql/core";
import { cacheExchange } from "@urql/exchange-graphcache";
import schema from "./gql/schema";
import type { MutationAddEmailArgs } from "./gql/graphql";
export const client = createClient({
url: "/graphql",
exchanges: [cacheExchange({ schema }), fetchExchange],
// XXX: else queries don't refetch on cache invalidation for some reason
requestPolicy: "cache-and-network",
exchanges: [
cacheExchange({
schema,
updates: {
Mutation: {
addEmail: (result, args: MutationAddEmailArgs, cache, _info) => {
const key = cache.keyOfEntity({
__typename: "User",
id: args.input.userId,
});
// Invalidate the emails field on the User object so that it gets refetched
cache
.inspectFields(key)
.filter((field) => field.fieldName === "emails")
.forEach((field) => {
cache.invalidate(key, field.fieldName, field.arguments);
});
},
},
},
}),
fetchExchange,
],
});