T
tRPC

❓-help

Property 'query' does not exist on type ...

Hhachoter9/27/2023
I think this is an issue on my end here is how I am defining everything
export const t = initTRPC.create();
export const t = initTRPC.create();
export const assetsRouter = t.router({
images: t.procedure.input(getImagesValidator).query(async ({ input }) => {
return await getImages(input);
}),
});
export const assetsRouter = t.router({
images: t.procedure.input(getImagesValidator).query(async ({ input }) => {
return await getImages(input);
}),
});
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
And in my client, I have this
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/trpc/server';

export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://127.0.0.1:4000/trpc'
})
]
});
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import type { AppRouter } from '../../../api/trpc/server';

export const client = createTRPCProxyClient<AppRouter>({
links: [
httpBatchLink({
url: 'http://127.0.0.1:4000/trpc'
})
]
});
But when I try to query like this client.assets.images.query i get an error property query does not exist, it correctly infers the type assets etc... but not query bump: any ideas?
AKAlex / KATT 🐱9/27/2023
can't you see any type errors here - you haven't added assetsRouter to the router nor imported menusRouter
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
import { assetsRouter } from "../apps/routes";
import { t } from "./t";
export const appRouter = t.router({
menus: menusRouter
});
// export type definition of API
export type AppRouter = typeof appRouter;
Hhachoter10/2/2023
I did add it, the same way I added menusRouter, the code was getting too long so I only showed how I am adding one router but I am adding all the routers in the same way, I am getting intellisense for the routes just not for the query property @Alex / KATT 🐱 Just switch menusRouter with assetsRouter and I am getting the same error

Looking for more? Join the community!

Recommended Posts
useQueries passing ctx data to splitLink not workingWhen tRPC is implemented with splitLink using useQueries does not pass cxt parameters to splitLink. Build and Publish on lambda from Github ActionsTrying to send my TRPC API on Lambda AWS + API Gateway. I have follow the documentation. But now honext-pwa with trpc and push notificationHow can I build an app with next-pwa, trpc and push notification?Forced router input?I have a user route which has routes like get, delete, create etc. Some of the routes I require extrAuthentication with Expo applicationHi guys, I wan't to convert my current application stack to T3 stack. Current stack is: - NestJSOne router multiple adapters?Hey all! This might be misguided question, but I'm working on building an api with tRPC that will betRPC Express server with Next.jsAs much as I hate this, I am required to use Express for back-end and Next.js for front-end. I haveis Nextjs enough as backend?Hi guys, I'm new to tRPC and would like to rewrite my current project to use single monorepo insteaTS(2742) error when trying to create clientNPM with Node v18.16.1. I get the following error when trying to create a client. I've imported allWrapping useQuery into a custom hookI'm trying to wrap `useQuery` into a custom hook (as I have some legacy code that I need to run befoPass additional data from `useQuery` to contextFor `splitLink` there is a way to pass context value through `useQuery` as second param `{ trpc: { cCannot set headers in procedures with fetch adapterAm i right that with such a setup in nextjs app router route handler: ```ts const handler = async (r