saas-backend-template
saas-backend-template copied to clipboard
Nestjs + Graphql
Hello, we are using Prisma with typegraphql and we want to know if it's possible to use your stack ? any POC or repo with nestjs examples ? Thanks you. have nice day.
Thanks for the inquiry. As we actually generate the Prisma schema file, you are supposed to use ZenStack in any place where Prisma is used.
However, for this particular template, since we haven’t supported generating GraphQL API, you still need to implement the resolver by yourself. Nonetheless, you can benefit from the enhanced Prima client with auto-generated access policies and validations defined in the schema. Here is an example project that uses ZenStack with a GraphQL server: https://github.com/jiashengguo/graphql-server-example
BTW, we are aware that typegraphql-prisma employed the triple comments way to do some annotation for itself like:
model User {
id Int @default(autoincrement()) @id
email String @unique
/// @TypeGraphQL.omit(output: true)
password String
}
There are two ways to achieve it in ZenStack:
-
The straightforward way is that you can use the exact same annotation in ZModel file. We preserve all the triple comments as it is when generating s
chema.prisma
-
The other way is to define the attribute yourself in ZModel like this:
model User { id Int @default(autoincrement()) @id email String @unique password String @TypeGraphQL.omit(output: true) } attribute @TypeGraphQL.omit(output: Boolean)
It will generate the same
schema.prisma
file as above and you get the strong syntax validation now.