mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-29 14:50:13 -05:00
suggested changes for trpc 5 (#357)
* suggested changes for trpc 5 * prettier format * add queryclient options * 5.0 Co-authored-by: Kalle (Sendou) <38327916+Sendouc@users.noreply.github.com>
This commit is contained in:
@@ -1,22 +1,16 @@
|
||||
import { createReactQueryHooks, createTRPCClient } from "@trpc/react";
|
||||
import type { AppRouter } from "pages/api/trpc/[trpc]";
|
||||
import { QueryClient } from "react-query";
|
||||
import superjson from "superjson";
|
||||
// Type-only import:
|
||||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export
|
||||
import type { AppRouter } from "../pages/api/trpc/[trpc]";
|
||||
|
||||
// create helper methods for queries, mutations, and subscriptionos
|
||||
export const client = createTRPCClient<AppRouter>({
|
||||
url: "/api/trpc",
|
||||
transformer: superjson,
|
||||
});
|
||||
|
||||
// create react query hooks for trpc
|
||||
export const trpc = createReactQueryHooks({
|
||||
client,
|
||||
queryClient: new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
// queries never go stale to save some work
|
||||
// on our poor database
|
||||
staleTime: Infinity,
|
||||
},
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user