`prisma introspect` breaking graphql queries
Hi all,
Issue: prisma introspect breaks the schema.prisma file.
I went through the typescript/graphql-auth example and ran into this issue on the step of adding the Profile table.
Upon running prisma introspect as per the example my schema.prisma file looks like this --
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
model User {
email String @unique
id Int @default(autoincrement()) @id
name String?
password String @default("")
Post Post[]
Profile Profile?
}
model Post {
authorId Int?
content String?
id Int @default(autoincrement()) @id
published Boolean @default(false)
title String
User User? @relation(fields: [authorId], references: [id])
}
model Profile {
bio String?
id Int @default(autoincrement()) @id
user String @unique
User User @relation(fields: [user], references: [id])
}
where it should instead look like this as per the example (not adding client & datasource as it doesn't seem relevant) --
model Post {
author User?
content String?
id Int @id
published Boolean @default(false)
title String
}
model User {
email String @unique
id Int @id
name String?
post Post[]
profile Profile?
}
model Profile {
bio String?
id Int @id
user User
}
As you can see it seems to pull the exact authorId field of the table as authorId instead of id and the biggest issue is: replacing the author field for the prisma schema to User
I understand why this is happening as introspecting doesn't know what author is, but by following the steps exactly for introspection in the example, I thought this was a feature of introspection (bc even the example has it...).
I used to use prisma migrate in prisma1, but since it's experimental in prisma2 I'm using prisma introspect as it the preferred way until migrate is out of experimental.
But not sure how prisma introspect could even support this functionality... but it is quite integral to prisma dev bc syncing the schema and db is one of the main advantages of prisma.
Is there something I'm missing? or is this the intended behavior and the example is incorrect?
Thanks~
I have the same problem with rest-nextjs example. The steps in Evolving the app does not seem to work.