Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma models made up of only relations breaks prisma generator #289

Closed
Atlinx opened this issue May 20, 2022 · 1 comment
Closed

Prisma models made up of only relations breaks prisma generator #289

Atlinx opened this issue May 20, 2022 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@Atlinx
Copy link

Atlinx commented May 20, 2022

Describe the Bug
If you declare in a schema.prisma file models that only contain relations and an id, the type-graphql prisma generator will fail.

To Reproduce

  1. Use this schema.prisma
generator client {
  provider = "prisma-client-js"
}

generator typegraphql {
  provider = "typegraphql-prisma"
}

datasource db {
  provider = "mongodb"
  url      = env("DB_URL")
}

model User {
  id              String              @id @default(auto()) @map("_id") @db.ObjectId
  email           String              
  roles           UserRole[]
}

model UserRole {
  id       String       @id @default(auto()) @map("_id") @db.ObjectId
  test     String
  type     UserRoleType @relation(fields: [typeId], references: [id])
  typeId   String
  member   User         @relation(fields: [memberId], references: [id])
  memberId String
}

model UserRoleType {
  id          String     @id @default(auto()) @map("_id") @db.ObjectId
  name        String     @unique
  roles       UserRole[]
  permissions String[]
  1. Have everything else configured correctly for prisma generation. ( )
  2. Run npx prisma generate
  3. See this error
Error: Some errors occurred while generating GraphQL Schema:
Input Object type UserRoleUpdateManyMutationInput must define one or more fields.

Expected Behavior
The type-graphql prisma generator should work successfully with no errors.

Environment (please complete the following information):

  • OS: Windows
  • Node: v17.6.0
  • Package version: v1.1.1
  • TypeScript version v4.6.4
@Atlinx Atlinx changed the title Prisma models made up of relations breaks prisma integration Prisma models made up of only relations breaks prisma generator May 20, 2022
@MichalLytek MichalLytek transferred this issue from MichalLytek/type-graphql May 20, 2022
@MichalLytek
Copy link
Owner

Duplicate of #19 🔒

@MichalLytek MichalLytek added the duplicate This issue or pull request already exists label May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants