| 1 | import { createORPCClient } from "@orpc/client"; |
| 2 | import { RPCLink } |
| 3 | import { createTanstackQueryUtils } |
| 4 | import type { AppRouterClient |
| 5 | import { MutationCache, QueryCache |
| 6 | import { toast } |
| 7 | |
| 8 | declare module "@tanstack/react-query" |
| 9 | interface Register |
| 10 | // Set `meta: { customError: true }` on a mutation to opt out of the |
| 11 | // generic error toast below when it already shows its own message. |
| 12 | mutationMeta: { |
| 13 | customError?: boolean |
| 14 | }; |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | export const queryClient = |
| 19 | queryCache: new QueryCache |
| 20 | onError: (error, |
| 21 | toast.error(`Error: |
| 22 | action: { |
| 23 | label: "retry", |
| 24 | onClick: query.invalidate |
| 25 | }, |
| 26 | }); |
| 27 | }, |
| 28 | }), |
| 29 | mutationCache: new MutationCache |
| 30 | onError: (error, |
| 31 | if (mutation.meta |
| 32 | toast.error(error |
| 33 | }, |
| 34 | }), |
| 35 | }); |
| 36 | |
| 37 | export const link = |
| 38 | url: `${typeof window |
| 39 | fetch(url, options |
| 40 | return fetch(url |
| 41 | ...options, |
| 42 | credentials: "include", |
| 43 | }); |
| 44 | }, |
| 45 | headers: async () |
| 46 | if (typeof window |
| 47 | return {}; |
| 48 | } |
| 49 | |
| 50 | const { headers |
| 51 | return Object.fromEntries |
| 52 | }, |
| 53 | }); |
| 54 | |
| 55 | export const client: |
| 56 | |
| 57 | export const orpc = |