hashwarp
hashwarp
TtRPC
Created by hashwarp on 1/1/2025 in #❓-help
Error: This is a client-only function.
It was working last week in 11.0.0-rc.660 but in 11.0.0-rc.682 it's not. I didn't change any code. I just rolled back and confirmed.
const createCaller = createCallerFactory(this.router);
const caller = createCaller(socket.ctx);
const result = params ? await caller[method](deserialize(params)) : await caller[method]();
const createCaller = createCallerFactory(this.router);
const caller = createCaller(socket.ctx);
const result = params ? await caller[method](deserialize(params)) : await caller[method]();
15|seer-node | If you want to call this function on the server, see https://trpc.io/docs/v11/server/server-side-calls 15|seer-node | at procedure (/opt/arken/common/temp/node_modules/.pnpm/@trpc+server@11.0.0-rc.682/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.js:175:19) 15|seer-node | at /opt/arken/common/temp/node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/config-194bdd43.js:182:24 15|seer-node | at Object.apply (/opt/arken/common/temp/node_modules/.pnpm/@trpc+server@10.45.2/node_modules/@trpc/server/dist/index-784ff647.js:69:20) 15|seer-node | at Socket.<anonymous> (/opt/arken/packages/seer/packages/node/src/index.ts:360:59) 15|seer-node | at Socket.emit (node:events:518:28) 15|seer-node | at Socket.emit (node:domain:488:12) 15|seer-node | at Socket.emitUntyped (/opt/arken/common/temp/node_modules/.pnpm/socket.io@4.7.5/node_modules/socket.io/dist/typed-events.js:69:22) 15|seer-node | at /opt/arken/common/temp/node_modules/.pnpm/socket.io@4.7.5/node_modules/socket.io/dist/socket.js:704:39 15|seer-node | at processTicksAndRejections (node:internal/process/task_queues:77:11)
2 replies
TtRPC
Created by hashwarp on 10/4/2024 in #❓-help
Typing on trpc.createClient?
Basically I want an asyncQuery I can call later, the way asyncMutate works. I can do this:
const profileData = await trpcClient.query(
'seer.evolution.getProfile',
'name'
);
const profileData = await trpcClient.query(
'seer.evolution.getProfile',
'name'
);
But I can't do this:
const profileData = await trpcClient.seer.evolution.getProfile.query('name');
const profileData = await trpcClient.seer.evolution.getProfile.query('name');
My code is like this:
// Define the merged router type
type MergedRouter = {
relay: RelayRouter;
evolution: EvolutionRouter;
seer: SeerRouter;
};

// Initialize tRPC with the merged context if needed
const t = initTRPC
.context<{
// Define any shared context here if necessary
}>()
.create();

// Create the root router
export const createRouter = () =>
t.router<MergedRouter>({
relay: createRelayRouter(),
evolution: createEvolutionRouter(),
seer: createSeerRouter(),
});

// Create a single tRPC instance
export const trpc = createTRPCReact<AppRouter>();

// Create the tRPC client with the combined link
export const trpcClient = trpc.createClient({
links: [combinedLink],
});
// Define the merged router type
type MergedRouter = {
relay: RelayRouter;
evolution: EvolutionRouter;
seer: SeerRouter;
};

// Initialize tRPC with the merged context if needed
const t = initTRPC
.context<{
// Define any shared context here if necessary
}>()
.create();

// Create the root router
export const createRouter = () =>
t.router<MergedRouter>({
relay: createRelayRouter(),
evolution: createEvolutionRouter(),
seer: createSeerRouter(),
});

// Create a single tRPC instance
export const trpc = createTRPCReact<AppRouter>();

// Create the tRPC client with the combined link
export const trpcClient = trpc.createClient({
links: [combinedLink],
});
Version: v11
2 replies
TtRPC
Created by hashwarp on 9/3/2024 in #❓-help
Router output types not mapping?
No description
4 replies
TtRPC
Created by hashwarp on 9/1/2024 in #❓-help
v11: inferRouterInputs is returning `void | <zod object>` so it's unusable?
No description
5 replies
TtRPC
Created by hashwarp on 8/30/2024 in #❓-help
Type too complex to infer?
No description
6 replies
TtRPC
Created by hashwarp on 8/25/2024 in #❓-help
createCaller is returning [Function: noop]
env: node 20 pnpm I'm trying to call procedures locally, and when I console log the router, I see the trpc object ({mutations: ..., etc.}) But when I create the caller, it returns noop, and anything I call on that is noop. Ideas?
client.emit = createRouter(service);

const createCaller = createCallerFactory(client.emit);
const caller = createCaller({ client );
const result = await caller.connected(params);
client.emit = createRouter(service);

const createCaller = createCallerFactory(client.emit);
const caller = createCaller({ client );
const result = await caller.connected(params);
router:
export const createRouter = (service: Schema.Service) => {
return router({
connected: procedure
.use(hasRole('realm', t))
.use(customErrorFormatter(t))
.input(schema.connected)
.mutation(({ input, ctx }) => service.connected(input as Schema.ConnectedInput, ctx))
})
}
export const createRouter = (service: Schema.Service) => {
return router({
connected: procedure
.use(hasRole('realm', t))
.use(customErrorFormatter(t))
.input(schema.connected)
.mutation(({ input, ctx }) => service.connected(input as Schema.ConnectedInput, ctx))
})
}
2 replies