Try   HackMD

Graphql with Prisma schema

Prisma

With Prisma, you can build GraphQL servers that connect to a database.

schema

Generate specified user id (customly)

@default
  • Defines a default value for a field .

  • Remarks
    Corresponding database type: DEFAULT

  • Default values can be a static value (4, "hello") or one of the following functions:

    • autoincrement()
    • dbgenerated()
    • cuid()
    • uuid()
    • now()

ex:

schema.prisma

​​​​ model User {
​​​​  id       Int      @id @default(autoincrement())
​​​​  email    String   @unique
​​​​  password String
​​​​  name     String?
​​​​  posts    Post[]
​​​​  profile  Profile?
​​​​}

​​​​model User {
​​​​  id       Int      @id @default(dbgenerated("gen_random_uuid()"))
​​​​}