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

Nestjs + Graphql #1

Open
StephaneLASOUR opened this issue Jul 11, 2023 · 1 comment
Open

Nestjs + Graphql #1

StephaneLASOUR opened this issue Jul 11, 2023 · 1 comment

Comments

@StephaneLASOUR
Copy link

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.

@jiashengguo
Copy link
Member

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 schema.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants