Transforms prisma schema into graphql schema
npm i prisma-generator-graphql-typedef
This prisma schema:
model User {
id Int @id @default(autoincrement())
/// @gqlType Float
createdAt DateTime @default(now())
/// @gqlType Float
updatedAt DateTime @updatedAt
/// @gqlIgnore
password String
email String @unique
name String?
keywords String[]
/// @gqlNonNullElement
posts Post[]
profile Profile?
/// user role
role Role @default(USER)
}
Will generate this graphql schema:
-
password field is not included because of the @gqlIgnore keyword
-
createdAt and updatedAt fields' type was changed to Float by using @gqlType Float, which you can supply any type
-
name and profile is optional that makes all the other fields non-null
-
posts is non null by using @gqlNonNullElement
type User {
id: Int!
createdAt: Float!
updatedAt: Float!
email: String!
name: String
keywords: [String]!
posts: [Post!]!
profile: Profile
role: Role!
}
This generator was bootstraped using create-prisma-generator