mavvystudio / prisma-generator-graphql-typedef

Generates graphql schema from prisma schema
11 stars 1 forks source link
graphql prisma

prisma-generator-graphql-typedef

Transforms prisma schema into graphql schema

Install

npm i prisma-generator-graphql-typedef

Example

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:

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