![](/img/trans.png)
[英]All my TRPC queries fail with a 500. What is wrong with my setup?
我是 TRPC 的新手,並在我的 NextJS 應用程序中設置了一個自定義掛鈎來進行查詢。 此掛鈎正在向generateRandomWorker發送查詢,但響應始終返回一般的 500 錯誤。 在我弄清楚這個問題之前,我完全被困住了。 鈎子: 這是路由器。 我知道WorkerService調用有效, ...
[英]All my TRPC queries fail with a 500. What is wrong with my setup?
我是 TRPC 的新手,並在我的 NextJS 應用程序中設置了一個自定義掛鈎來進行查詢。 此掛鈎正在向generateRandomWorker發送查詢,但響應始終返回一般的 500 錯誤。 在我弄清楚這個問題之前,我完全被困住了。 鈎子: 這是路由器。 我知道WorkerService調用有效, ...
[英]Next-Auth signIn: Promise-returning function provided to attribute where a void return was expected
<button onClick={() => signIn()}>Login</button>在 VS Code 中出現以下@typescript-eslint/no-misused-promises錯誤: Promise-returning function pr ...
[英]Typescript overloading unnamed function in trpc
我有一條典型的 trpc 路線。 它獲取posts 。 如果有 id 參數,它會獲取 1 個帖子。 如果沒有,它會獲取所有帖子。 重載未命名的 function 的語法是什么,在這種情況下我應該把重載代碼放在哪里?publicProcedure .input(z.object({ id: ...
[英]How to setup tRPC project with pnpm
我正在嘗試從這個 repo中學習。 安裝說明的第 3 步說運行 yarn dx。 此 repo 的 package.json 將該腳本定義為: 當我嘗試這樣做時,我收到一條錯誤消息: 紗線 dx 紗線運行 v1.22.19 $ run-p dx:* --print-label [dx:next ] ...
[英]tRPC setData hook doesn't have access to all data for optimistic ui updates
我正在使用 tRPC 和 React Query 構建突變,在添加新項目時樂觀地更新我的 UI,但我遇到了問題。 我正在更新的查詢需要一定數量的屬性,這些屬性要么是自動生成的,例如 ID,要么是來自數據庫的關系,例如標簽等。是否有類型安全的方法來解決這個問題,所以我可以使用傳遞給onMutate回調 ...
[英]Obtaining typescript type of trpc or react-query's useQuery result "data" property
在我的 React + TRPC 應用程序中,我在客戶端調用const { data: promotion } = trpc.promotions.getPromotion.useQuery({ id: promotionId }) 。 通過查看實際服務器端代碼的返回類型來檢測promotion的類 ...
[英]Rerendering of one sibling component due to data update in other sibling component in Next JS
我有一個 Next JS 應用程序,我在其中使用_app.tsx組件中的布局功能。 我在布局中顯示了一個側邊欄,該側邊欄是通過 api 調用(獲取請求)填充的。 現在我在Index.tsx文件中單擊按鈕時有另一個 api 調用(更新請求)。 此更新請求更改布局側邊欄組件中的數據。 這是我的代碼片段_ ...
[英]How to redirect on tRPC error in SvelteKit?
我第一次將tRPC與 SvelteKit 一起使用,我一直在嘗試驗證用戶的身份驗證。 我在hooks.server.ts中有以下內容: 我的問題是:如果error.code是UNAUTHORIZED ,我如何將trpcHandleError中的用戶重定向到/login ? 我試過簡單地throw ...
[英]Signin method with Nextjs and trpc returning resolver is not a function
因此,我嘗試構建我的注冊方法,而無需使用 nextjs、trpc 和 nextauth 重新發明 create-t3-app 堆棧的任何瘋狂內容: 這個文件在 pages/api/auth/signup.ts 里面 我應該在服務器部分有這個嗎? 我的 appRouter 文件中有路由器 當點擊注冊按 ...
[英]Conditional keys based on value of another key with Zod
我正在用 TMDB API 做一個項目,並試圖讓它超級類型安全,以加強我正在學習的一些 TypeScript 的東西。 我正在使用 Zod 來描述 API 返回的數據的形狀。 但是,我注意到根據請求參數,API 可以使用不同的密鑰發回數據。 具體來說,如果 API 從data.media_type ...
[英]How do I invalidate queries and fetch latest data in TRPC?
我只是想在執行突變后從服務器獲取最新數據。 我的代碼看起來像這樣: ...
[英]tRPC throws an error in setData (useContext wrapper of TanStack Query) after I updated it from v10-rc to v10
Before: ├── @tanstack/react-query@4.14.6 ├── @trpc/client@10.0.0-rc.4 ├── @trpc/next@10.0.0-rc.4 ├── @trpc/react-query@10.0.0-rc.4 ├── @trpc ...
[英]Build errors when trying to deploy trpc websocket example repo to render.com following repo instructions
這個示例 trpc 項目使用 Render.com 來部署使用 trpc 和 ws 的 repo。 似乎某些依賴項在部署時沒有正確安裝。 我所做的只是克隆到 repo 並連接 render.yaml 藍圖。 數據庫部署正確,但 Web 服務產生以下錯誤。 ...
[英]Optimistic Updates with React-Query (TRPC)
我不確定如何使用 trpc 進行樂觀更新? 這是“內置”還是我必須使用 react-query 的 useQuery 鈎子? 到目前為止,我正在嘗試這樣做,但它不起作用: const queryClient = useQueryClient(); const updateWord = tr ...
[英]TRPC: Property 'useInfiniteQuery' does not exist on type '{ useQuery:
TRPC問題我有這個帶有時間線查詢的 tweetRouter,它返回推文和 NextCursor,但是當我嘗試訪問我的組件中的 useInfiniteQuery 時,出現錯誤。 ** 類型 '{ useQuery: ** 上不存在屬性 'useInfiniteQuery' 翻譯:您正在嘗試訪問 ...
[英]tRPC mutateAsync returns nothing
這是我第一次嘗試使用 tRPC。 我創建了一個名為“add”的突變,它接收一個 URL 作為參數並返回一個硬編碼的 slug 路由器 用法 但是,它只打印一個空的 object ( {} ) 我究竟做錯了什么? 完整源代碼https://github.com/skhaz/url-shortener ...
[英]TRPC Test Wrapper for unit and integration testing using jest and react testing library - client mock
您如何使用 jest 和 react 測試庫模擬 TRPC 客戶端以進行單元和集成測試? ...
[英]Trying to code using tRPC and T3 stack with no internet connection
嘗試離線編碼時 tRPC 或 T3 堆棧中斷怎么辦? 我的 console.log 在線時被調用,但當我嘗試離線編碼時,該過程不會被調用。 ...
[英]Typescript, losing Zod and tRPC types across monorepo projects, types result in any
我的處境有點奇怪。 在過去的 2 周里,我一直在嘗試調試為什么我在 monorepo 中的項目之間丟失類型。 我的后端公開了我的客戶使用的類型,但由於某種原因,某些類型無法通過並成為any . 這讓我有一段時間無法在這個項目上開發任何東西。 我根據問題制作了一個樣本回購以進一步展示它。 該項目是使用 ...
[英]Cannot access the user-object in tRPC createContext (express)
我遇到一個問題,我的 tRPC 配置無法根據請求 object 訪問快遞 session。 我將 passport.js 與 google 和 facebook 提供商一起使用,並且在任何正常的 http 路由(不在 tRPC 路由器上)上,我在調用req.user時獲得了用戶信息。 應用程序:i ...