Prefetch forEach
Hello, I'm trying to prefetch a list of procedures like this
How can typesafe the path of the router and the procedure?
How can typesafe the path of the router and the procedure?
type QueryKeys = {
// how to type this?
path: [string, string];
params: Partial<{ [key in keyof Key]: string }>;
};
const prefetchProcedures = (ids: QueryKeys[]) => {
const utils = trpc.useContext();
// [{path:["zones", "allSectors"], params: { zoneId: z.id }},{path: ["sectors", "allWalls"], params: { sectorId: s.id }]}
ids.forEach((i) => {
utils[i.path[0]][i.path[1]].prefetch(i.params);
});
};