Closed suiramdev closed 1 year ago
It can't be a import type DeleteManyUserArgs
as it's erased during compilation and TypeGraphQL has no type reflection available for @Args() args: DeleteManyUserArgs
Oh. Sorry for taking up your time. In fact, that was the cause of the problem, now I get it. For anyone who cares, here is what my resolver looks like, so :
import { Resolver, Mutation, Ctx, Arg } from "type-graphql";
import {
User,
UserWhereInput,
UserWhereUniqueInput,
AffectedRowsOutput,
} from "@generated/type-graphql";
import { GraphQLError } from "graphql";
import { Context } from "@/context";
@Resolver(() => User)
export class UserResolver {
@Mutation(() => AffectedRowsOutput)
async deleteManyUser(@Ctx() ctx: Context, @Arg("where") where: UserWhereInput): Promise<AffectedRowsOutput> {
return ctx.prisma.user.deleteMany({ where: { ...where, persistent: false }});
}
@Mutation(() => User, { nullable: true })
async deleteOneUser(@Ctx() ctx: Context, @Arg("where") where: UserWhereUniqueInput): Promise<User | null> {
const user = await ctx.prisma.user.findUnique({ where });
if (!user) return null;
if (user.persistent) throw new GraphQLError("Cannot delete a persistent user");
return ctx.prisma.user.delete({ where });
}
}
Describe the Bug So it was several months before I got my hands on my code again, and since I'd learned a lot, I decided to start from scratch. It turns out that, when I try to replace the behavior of one of the generated CRUDs (which was originally working ?), in this case deleteMany and deleteOne, I get an error with typescript :
I can't figure out why, I've tried a bunch of things, and it sometimes warns me of the same thing on the @Ctx() field.