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()"))
โ€‹โ€‹โ€‹โ€‹}