vansh
TTCTheo's Typesafe Cult
•Created by vansh on 11/23/2023 in #questions
I was trying to make an app using tRPC, prisma and neon database I am facing some issues
So what I wanna do is push details of a playlist into DB
Here is what I have defined in my trpc/index.ts :
Here is how I am trying to call the api :
It's throwing an error which is :
I have no clue how to fix this, help
createPlaylist: privateProcedure.input(
z.object({
playlistId: z.string(),
description: z.string(),
title: z.string(),
})).mutation(async ({ ctx, input }) => {
const { userId } = ctx;
return await db.playlist.create({
data: {
userId,
playlistId: input.playlistId,
description: input.description,
title: input.title,
},
});
createPlaylist: privateProcedure.input(
z.object({
playlistId: z.string(),
description: z.string(),
title: z.string(),
})).mutation(async ({ ctx, input }) => {
const { userId } = ctx;
return await db.playlist.create({
data: {
userId,
playlistId: input.playlistId,
description: input.description,
title: input.title,
},
});
interface PlaylistInput {
playlistId: string;
title: string;
description: string;
}
trpc.createPlaylist.useMutation({
playlistId: playlistID,
title: playlistTitle,
description: playlistDescription,
});
interface PlaylistInput {
playlistId: string;
title: string;
description: string;
}
trpc.createPlaylist.useMutation({
playlistId: playlistID,
title: playlistTitle,
description: playlistDescription,
});
Argument of type '{ playlistId: string; title: string; description: string; }' is not assignable to parameter of type 'UseTRPCMutationOptions<{ title: string; description: string; playlistId: string; }, TRPCClientErrorLike<BuildProcedure<"mutation", { _config: RootConfig<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; ... 5 more ...; _output_out: unique symbol; }, { ...; }>>, { .....'.
Object literal may only specify known properties, and 'playlistId' does not exist in type 'UseTRPCMutationOptions<{ title: string; description: string; playlistId: string; }, TRPCClientErrorLike<BuildProcedure<"mutation", { _config: RootConfig<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; ... 5 more ...; _output_out: unique symbol; }, { ...; }>>, { .....'.ts(2345)
Argument of type '{ playlistId: string; title: string; description: string; }' is not assignable to parameter of type 'UseTRPCMutationOptions<{ title: string; description: string; playlistId: string; }, TRPCClientErrorLike<BuildProcedure<"mutation", { _config: RootConfig<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; ... 5 more ...; _output_out: unique symbol; }, { ...; }>>, { .....'.
Object literal may only specify known properties, and 'playlistId' does not exist in type 'UseTRPCMutationOptions<{ title: string; description: string; playlistId: string; }, TRPCClientErrorLike<BuildProcedure<"mutation", { _config: RootConfig<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>; ... 5 more ...; _output_out: unique symbol; }, { ...; }>>, { .....'.ts(2345)
5 replies