hachoter
hachoter9mo ago

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

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
3 Replies
hachoter
hachoter9mo ago
bump: any ideas?
Alex / KATT 🐱
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;
hachoter
hachoter8mo ago
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