maoosi / prisma-appsync

⚡ Turns your ◭ Prisma Schema into a fully-featured GraphQL API, tailored for AWS AppSync.

Home Page:https://prisma-appsync.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue: All fields with `@default(xxx)` should be optional in GraphQL Schema

Tenrys opened this issue · comments

commented

I would expect to be able to omit required fields that have a default value entirely, so that the database can fill them up for me if I choose not to specify them, but it looks like a field is only considered "auto-populated" under very specific conditions:

private isFieldAutoPopulated(searchField: DMMF.Field): boolean {
const defaultValue: any = searchField?.default || null
return (
defaultValue?.name === 'autoincrement'
|| defaultValue?.name === 'uuid'
|| defaultValue?.name === 'cuid'
|| searchField.isUpdatedAt
|| ['updatedAt', 'createdAt'].includes(searchField.name)
)
}

Shouldn't it just be flagged as such as long as it has a valid @default attributes?

Will be release as part of 1.0.0-rc.6.