omar-dulaimi / prisma-trpc-generator

Prisma 2+ generator to emit fully implemented tRPC routers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@ignore causes TypeScript compilation error due to missing upsert methods

amiran-gorgazjan opened this issue · comments

Bug description

If a model has an @ignore tag, the prisma-trpc-generator will (I'm assuming correctly) not output the upsert and createOne methods for User, but at the same time will still import the schemas which now don't exist and cause a compilation error.

How to reproduce

Given a schema

model User {
  id       Int     @id @default(autoincrement())
  email    String  @unique
  name     String?
  password String  @ignore
}

You should get the compilation error:

// generated/routers/User.router.ts
import { t, publicProcedure } from "./helpers/createRouter";
import { UserFindUniqueSchema } from "../schemas/findUniqueUser.schema";
import { UserFindFirstSchema } from "../schemas/findFirstUser.schema";
import { UserFindManySchema } from "../schemas/findManyUser.schema";
import { UserCreateOneSchema } from "../schemas/createOneUser.schema"; // Cannot find module
import { UserDeleteOneSchema } from "../schemas/deleteOneUser.schema";
import { UserUpdateOneSchema } from "../schemas/updateOneUser.schema";
import { UserDeleteManySchema } from "../schemas/deleteManyUser.schema";
import { UserUpdateManySchema } from "../schemas/updateManyUser.schema";
import { UserUpsertSchema } from "../schemas/upsertOneUser.schema"; // Cannot find module
import { UserAggregateSchema } from "../schemas/aggregateUser.schema";
import { UserGroupBySchema } from "../schemas/groupByUser.schema";

Expected behavior

import { UserUpsertSchema } from "../schemas/upsertOneUser.schema";

and

import { UserCreateOneSchema } from "../schemas/createOneUser.schema";

Should not be present in the User.router.ts file

Prisma information

model User {
  id       Int     @id @default(autoincrement())
  email    String  @unique
  name     String?
  password String  @ignore
}

Environment & setup

N/A

Prisma Version

4.10.1

Hey, could you share your db block in the Prisma schema file?