T
tRPC

NextJS & Keystone CMS, issues when connecting both in a monorepo

NextJS & Keystone CMS, issues when connecting both in a monorepo

W.westsaid10/11/2022
Hello everyone, so I have a monorepo with NextJS and keystone cms, both are running trpc v10beta.15. Screenshot 1: I receive a type error when trying to use the CmsAppRouter type in my NextJS when calling createTRPCProxyClient. Screenshot 2: The tRPC files in the cms. Does someone has a clue? Would be really thankful for any help 🙂 (Full error msg below)
W.westsaid10/12/2022
Full Error Message
Type 'CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC_ERROR_COD...' does not satisfy the constraint 'Router<any>'.
The types returned by 'createCaller(...)' are incompatible between these types.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
Types of property 'query' are incompatible.
Type 'inferHandlerFn<{}>' is not assignable to type 'inferHandlerFn<any>'.
Types of parameters 'path' and 'path' are incompatible.
Type 'TPath' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.
Type 'CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC_ERROR_COD...' does not satisfy the constraint 'Router<any>'.
The types returned by 'createCaller(...)' are incompatible between these types.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; } & DecoratedProcedureRecord<any>'.
Type '{ query: inferHandlerFn<{}>; mutation: inferHandlerFn<{}>; subscription: inferHandlerFn<{}>; } & DecoratedProcedureRecord<{ translations: CreateRouterInner<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<...>; }; meta: {}; errorShape: { ...; }; transformer: CombinedDataTransformer; }, { ...;...' is not assignable to type '{ query: inferHandlerFn<any>; mutation: inferHandlerFn<any>; subscription: inferHandlerFn<any>; }'.
Types of property 'query' are incompatible.
Type 'inferHandlerFn<{}>' is not assignable to type 'inferHandlerFn<any>'.
Types of parameters 'path' and 'path' are incompatible.
Type 'TPath' is not assignable to type 'never'.
Type 'string' is not assignable to type 'never'.
This can be considered closed. There was a problem with the config of the monorepo and the installed packages
UUUnknown User10/24/2022
Message Not Public
Sign In & Join Server To View
W.westsaid10/24/2022
Hi, I deleted node_modules, rechecked my monorepo configuration and reinstalled. The error disappeared. @Matheus Mazeto
UUUnknown User10/24/2022
2 Messages Not Public
Sign In & Join Server To View
W.westsaid10/25/2022
Yes, turborepo. I reinstalled using yarn, then it worked Okay, I have to rollback, installed my repo on a new Pc, same issue again :/
Type 'CreateRouterInner<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | "BAD_REQUEST" | ... 10 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: s...' does not satisfy the constraint 'Router<any>'.
Type 'Router<RouterDef<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC...' is missing the following properties from type 'Router<any>': errorFormatter, transformerts(2344)
Type 'CreateRouterInner<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | "BAD_REQUEST" | ... 10 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: s...' does not satisfy the constraint 'Router<any>'.
Type 'Router<RouterDef<RootConfig<{ ctx: { opts: CreateExpressContextOptions; keystoneCtx: KeystoneContext<TypeInfo>; }; meta: {}; errorShape: { data: { code: "PARSE_ERROR" | ... 11 more ... | "CLIENT_CLOSED_REQUEST"; httpStatus: number; path?: string | undefined; stack?: string | undefined; }; message: string; code: TRPC...' is missing the following properties from type 'Router<any>': errorFormatter, transformerts(2344)
If you or someone else want to start a debugging session sometimes hit me up. We could also set up an example project with "tRPC X Keystone JS CMS" which could be featured on the tRPC website Im setting up a boiled down version of this repo to debug and maybe feature later on rn!
UUUnknown User12/26/2022
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

T
tRPC

NextJS & Keystone CMS, issues when connecting both in a monorepo

Join Server
Recommended Posts
Best practices for implementing an offline applicationHey there! I'm building a full stack react-native app with Expo and a tRPC backend. I'd like for thisomehow when move typed function out of the router files, frontend infer type to be any ?this is inferred corrected since they are in the same file. ``` getX: t.procedure.query(() => { retBig companies that use tRPC?Some of my fellow colleagues were wondering if there are any big companies that use tRPC and how matMigrating to V10 from V9If someone has some ideas on what I might have screwed up when trying to bump tRPC for this public sAuthentication broke after bump to v10 from v9Anyone that has any suggestions on what might have caused this? I get the following error when tryiShow a spinner when any mutation is loading?Looking to show an activity spinner in the header of our application whenever a mutation is in flighSharing schemas between server and clientIn a typical nextJs setup, what is the idiomatic way to share zod schemas between frontend and backev10 Migration interop, router doesnt have attributesHi, i've tried to migrate like stated in the docs, these are my routers. Question: Shouldn't appRoutRecommended file structure for next.js?Hey all - using tRPC heavily with next.js and it's great. Our main `[trpc].ts` file is getting huge Unhandled Runtime ErrorTRPCClientErrorCall Stack Function.from node_modules\@trpc\client\dist\TRPCClientError-09b8a26b.esm.js (57:0) transSharing middleware between TRPC serversWe currently have *microservices* REST API's on Cloudflare Workers and I'm thinking about moving thiIs `trpc.withTRPC` for Next supposed to work with pages or only `_app`?I'd love to only have TRPC mount on certain pages of my Next.js app. Is this currently supported?Are there any example of subscriptions working with react native ?queries and mutations are working pretty well with react native, I'm unable however to get subscriptRecommended way to prefetch client-sideIn react-query, you can do ``` queryClient.prefetchQuery(['todos', input], queryFn) ``` In trpc, IRevalidate API route from procedureHi, is there a way to revalidate a statically generated page from a trpc procedure? https://nextjs.Modifying payload client-side before cachingSay I have a payload that includes something like `category_id` in each of the items returned e.g.: Response headersIs it possible to modify the response headers from server to client?API Response caching not working on vercel ⁉I've followed the instructions in https://trpc.io/docs/v9/caching for API Response caching and it's when throwing a TRPCError, is there a way to include an internal error code ?for the given screenshot, if such error happens I wanna prompt the user to login or something.