shikishikichangchang
shikishikichangchang
TtRPC
Created by shikishikichangchang on 10/22/2024 in #❓-help
trpc version 11.0.0-rc.383 breaks turbo
I was seeing a MODULE_UNPARSEABLE error when running with the latest trpc rc. I did a bisect and found 11.0.0-rc.383 to be the breaking version. 11.0.0-rc.382 works fine. Only happens when running with next dev --turbo. next dev is fine
3 replies
TtRPC
Created by shikishikichangchang on 10/16/2024 in #❓-help
Trpc server actions
Are there any plans to bump server actions out from experimental? I like trpc a lot. But server actions being 'experimental' is a little worrying. Been looking at libraries like zsa and next-safe-action. Would like to stay with trpc.
8 replies
TtRPC
Created by shikishikichangchang on 10/9/2024 in #❓-help
Override output schema for certain mutations
Is it possible to overrider output schema's type for certain mutations? Currently I have a base procedure that has an outputschema as such:
import { z } from "zod";

const successSchema = z.object({
status: z.literal("success"),
data: z.any(),
});

const errorSchema = z.object({
status: z.literal("error"),
errorMessage: z.string(),
});

export const outputSchema = z.discriminatedUnion("status", [successSchema, errorSchema]);
export type Output = z.infer<typeof outputSchema>;
import { z } from "zod";

const successSchema = z.object({
status: z.literal("success"),
data: z.any(),
});

const errorSchema = z.object({
status: z.literal("error"),
errorMessage: z.string(),
});

export const outputSchema = z.discriminatedUnion("status", [successSchema, errorSchema]);
export type Output = z.infer<typeof outputSchema>;
As you can see, data is z.any(). For most mutations I don't need to return the data so that's not a problem. However, I want to return the data with the correct type for some. The output must have either z.literal("success") or z.literal("error"). I tried to add an extra '.output' but it seems like trpc only allows for one (no chaining to override).
3 replies
TtRPC
Created by shikishikichangchang on 4/10/2024 in #❓-help
Unexpected token
Works fine locally, doesn't work when deployed to AWS via sst.dev. Was working last night. Redeployed the app today with no changes, started failing. Please help
8 replies
TtRPC
Created by shikishikichangchang on 3/29/2024 in #❓-help
keep previous data
Trpc 11 (trpc@next) doesn’t have support for keepPreviousData? I’m trying to useQuery with keepPreviousData but can’t be used
4 replies