Skip to content

Commit

Permalink
feat: disable trpc batching (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
karrui authored Jan 20, 2025
1 parent 219a1f2 commit 47dd372
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
type ReactRenderer,
} from '@storybook/react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { httpBatchLink } from '@trpc/client'
import { httpLink } from '@trpc/client'
import { createTRPCReact } from '@trpc/react-query'
import { format } from 'date-fns/format'
import merge from 'lodash/merge'
Expand Down Expand Up @@ -71,7 +71,7 @@ const SetupDecorator: Decorator = (story) => {
)
const [trpcClient] = useState(() =>
trpc.createClient({
links: [httpBatchLink({ url: '' })],
links: [httpLink({ url: '' })],
transformer: superjson,
}),
)
Expand Down
8 changes: 4 additions & 4 deletions src/pages/api/trpc/[trpc].ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export default trpcNext.createNextApiHandler({
ctx?.session?.destroy()
}
},
/**
* Enable query batching
*/
batching: {
enabled: true,
/**
* Disable query batching for better logging (and since we mostly self-host the app without Serverless)
*/
enabled: false,
},
/**
* @link https://trpc.io/docs/caching#api-response-caching
Expand Down
4 changes: 2 additions & 2 deletions src/utils/trpc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NextPageContext } from 'next'
import {
httpBatchLink,
httpLink,
loggerLink,
TRPCClientError,
type TRPCLink,
Expand Down Expand Up @@ -156,7 +156,7 @@ export const trpc = createTRPCNext<
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
}),
httpBatchLink({
httpLink({
url: `${getBaseUrl()}/api/trpc`,
/**
* Provide a function that will invoke the current global
Expand Down

1 comment on commit 47dd372

@vercel
Copy link

@vercel vercel bot commented on 47dd372 Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.