apollo.ts

 1import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
 2import { createQueryPreloader } from "@apollo/client/react";
 3
 4const httpLink = new HttpLink({
 5  uri: "/graphql",
 6  // include credentials so future httpOnly auth cookies are sent automatically
 7  credentials: "include",
 8});
 9
10export const client = new ApolloClient({
11  link: httpLink,
12
13  cache: new InMemoryCache({
14    typePolicies: {
15      // Repository has no id field — treat as a singleton per cache
16      Repository: {
17        keyFields: [],
18      },
19    },
20  }),
21});
22
23// Preloader for use in TanStack Router loaders. Returns a QueryRef
24// that components read with useReadQuery() for suspense-based rendering.
25export const preloadQuery = createQueryPreloader(client);