Search code examples
graphqlprismaprisma-graphql

How to Create Computed Values in @default Directives


Can anyone point me in the right direction? Using Prisma's SDL I’d like to create a computed value with the @default directive like this…

type Event {
  id: ID! @unique

  title: String!
  slug: String! @unique @default(value: titleToSlug())
}

Solution

  • Dynamic default values are currently not supported, and can be handled in the application server layer. You can create a feature request for dynamic default values here.

    The directive is called @default and not @defaultValue as described in the documentation.