CreateMany mutation broken
cnf-blueware opened this issue · comments
Bug description
Seems like Prisma createMany api has changed.
./prisma/generated/routers/Company.router.ts:27:69
Type error: Argument of type '{ data: CompanyCreateInput; }' is not assignable to parameter of type '{ data: Enumerable; skipDuplicates?: boolean | undefined; }'.
Types of property 'data' are incompatible.
Type 'CompanyCreateInput' is not assignable to type 'Enumerable'.
Type 'CompanyCreateInput' is missing the following properties from type 'CompanyCreateManyInput[]': length, pop, push, concat, and 29 more.
25 | input: CompanyCreateSchema,
26 | async resolve({ ctx, input }) {
27 | const createManyCompany = await ctx.prisma.company.createMany(input);
| ^
28 | return createManyCompany;
29 | },
30 | })
How to reproduce
npx prisma generate
Expected behavior
Getting
.mutation("createManyCompany", {
input: CompanyCreateSchema,
async resolve({ ctx, input }) {
const createManyCompany = await ctx.prisma.company.createMany(input);
return createManyCompany;
},
})
Working code after changing to the createmanyobjectschema
.mutation("createManyCompany", {
input: CompanyCreateManyInputObjectSchema,
async resolve({ ctx, input }) {
const createManyCompany = await ctx.prisma.company.createMany({ data: input });
return createManyCompany;
},
})
Prisma information
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator trpc {
provider = "prisma-trpc-generator"
withMiddleware = false
withShield = false
contextPath = "~/server/context"
}
model Company {
id Int @id @default(autoincrement())
companyMachines CompanyMachine[]
}
model Machine {
id Int @id @default(autoincrement())
companyMachines CompanyMachine[]
}
model CompanyMachine {
id Int @id @default(autoincrement())
company Company @relation(fields: [companyId], references: [id])
companyId Int
machine Machine @relation(fields: [machineId], references: [id])
machineId Int
}
Environment & setup
- OS:
- Mac OS
- Database:
- PostgreSQL
- Node.js version:
18.4.0
Prisma Version
4.0.0
Hello @cnf-blueware
Yes, it's a bug. Let me see.
Should be fixed in https://github.com/omar-dulaimi/prisma-trpc-generator/releases/tag/0.3.1