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

Use the same pagination primitives in the session lists

This commit is contained in:
Quentin Gliech
2023-04-27 20:25:15 +02:00
parent d7403ca0fd
commit 3d6eba6acc
11 changed files with 560 additions and 109 deletions

View File

@@ -14,10 +14,12 @@
import { createClient, fetchExchange } from "@urql/core";
import { cacheExchange } from "@urql/exchange-graphcache";
import { devtoolsExchange } from "@urql/devtools";
import { refocusExchange } from "@urql/exchange-refocus";
import schema from "./gql/schema";
import type { MutationAddEmailArgs } from "./gql/graphql";
import { devtoolsExchange } from "@urql/devtools";
import { requestPolicyExchange } from "@urql/exchange-request-policy";
const cache = cacheExchange({
schema,
@@ -41,9 +43,24 @@ const cache = cacheExchange({
},
});
const exchanges = [
// This sets the policy to 'cache-and-network' after 5 minutes
requestPolicyExchange({
ttl: 1000 * 60 * 5, // 5 minute
}),
// This refetches all queries when the tab is refocused
refocusExchange(),
// The unified cache
cache,
// Use `fetch` to execute the requests
fetchExchange,
];
export const client = createClient({
url: "/graphql",
exchanges: import.meta.env.DEV
? [devtoolsExchange, cache, fetchExchange]
: [cache, fetchExchange],
// Add the devtools exchange in development
exchanges: import.meta.env.DEV ? [devtoolsExchange, ...exchanges] : exchanges,
});