Curious why not null fields with a default value a...
# orm-help
c
Curious why not null fields with a default value are required by Prisma Client when creating a record?
r
@Chris Tsongas 👋 They aren’t required. What version of Prisma are you on?
c
3.3.0
r
Cannot reproduce unfortunately. I have this schema:
Copy code
model UserList {
  id   Int    @id @default(autoincrement())
  name String
  age  Int    @default(20)
}
And here’s the type generated:
Have you defined your own custom types for create or the input coming in?
c
Can you try a boolean? I noticed it for fields like
active Boolean @default(true)
being required. I can try to reproduce.
👀 1
r
Nope, still optional:
c
Oops I think I'm looking at the types generated by GraphQL Codegen not Prisma Client 🤦‍♂️
Where can I find my Prisma Client types? Is there a way to jump to a type definition from the VS Code editor? When I hover over a Prisma Client method, I just get a popup where I can only see 5 of 40 fields and there's no link....
r
Yup. Just
ctrl+click
on the method i.e.
prisma.model.create
and it will jump to the types.
c
Looks like they are in
./prisma/client/index.d.ts
I think the problem is that we have mappers set up for GraphQL Codegen to use Prisma models but not inputs, if that makes sense. Got our wires crossed.
r
Are you using Codegen directly on the Prisma model?
c
I think partly...here's our
codegen.yml
which I believe is looking at the Prisma models, however the input types still get generated from our Apollo schema:
Copy code
schema: './src/schema/**/*.ts'
generates:
  src/generated/resolvers-types.ts:
    plugins:
      - 'typescript'
      - 'typescript-resolvers'
    config:
      useIndexSignature: true # needed to work with Apollo Server
      contextType: ../types/index#Context
      mapperTypeSuffix: Model
      resolverTypeWrapperSignature: Promise<Partial<T>> | Partial<T>;
      mappers:
        Call: '@prisma/client/index.d#Call'
        Case: '@prisma/client/index.d#Case'
        CaseAction: '@prisma/client/index.d#CaseAction'
        CaseActionLog: '@prisma/client/index.d#CaseActionLog'
        CaseActionLogDocument: '@prisma/client/index.d#CaseActionLogDocument'
        CaseAnswer: '@prisma/client/index.d#CaseAnswer'
        CaseDocument: '@prisma/client/index.d#CaseDocument'
        CaseNote: '@prisma/client/index.d#CaseNote'
        CaseQuestion: '@prisma/client/index.d#CaseQuestion'
        CaseStatusLog: '@prisma/client/index.d#CaseStatusLog'
        CaseType: '@prisma/client/index.d#CaseType'
        ChatChannel: '@prisma/client/index.d#ChatChannel'
        ChatPost: '@prisma/client/index.d#ChatPost'
        Content: '@prisma/client/index.d#Content'
        Contract: '@prisma/client/index.d#Contract'
        Download: '@prisma/client/index.d#Download'
        Downtime: '@prisma/client/index.d#Downtime'
        Election: '@prisma/client/index.d#Election'
        ElectionCandidate: '@prisma/client/index.d#ElectionCandidate'
        ElectionPosition: '@prisma/client/index.d#ElectionPosition'
        ElectionRatification: '@prisma/client/index.d#ElectionRatification'
        ElectionVote: '@prisma/client/index.d#ElectionVote'
        Email: '@prisma/client/index.d#Email'
        EmailAttachment: '@prisma/client/index.d#EmailAttachment'
        EmailRecipient: '@prisma/client/index.d#EmailRecipient'
        EmailTopic: '@prisma/client/index.d#EmailTopic'
        Employee: '@prisma/client/index.d#Employee'
        EmployeeHistory: '@prisma/client/index.d#EmployeeHistory'
        EmployeeNote: '@prisma/client/index.d#EmployeeNote'
        EmployeeQualification: '@prisma/client/index.d#EmployeeQualification'
        EmployeeSearch: '@prisma/client/index.d#EmployeeSearch'
        EmployeeTag: '@prisma/client/index.d#EmployeeTag'
        EmployeeWorkLocation: '@prisma/client/index.d#EmployeeWorkLocation'
        Event: '@prisma/client/index.d#Event'
        EventException: '@prisma/client/index.d#EventException'
        EventPosition: '@prisma/client/index.d#EventPosition'
        Language: '@prisma/client/index.d#Language'
        Membership: '@prisma/client/index.d#Membership'
        MembershipLink: '@prisma/client/index.d#MembershipLink'
        Organization: '@prisma/client/index.d#Organization'
        OrganizationAssignment: '@prisma/client/index.d#OrganizationAssignment'
        Point: '@prisma/client/index.d#Point'
        PointRedemption: '@prisma/client/index.d#PointRedemption'
        PointReward: '@prisma/client/index.d#PointReward'
        Representative: '@prisma/client/index.d#Representative'
        Setting: '@prisma/client/index.d#Setting'
        Upload: '@prisma/client/index.d#Upload'
        UploadError: '@prisma/client/index.d#UploadError'