Skip to content

Setting the auth doesn't include relations #422

@genu

Description

@genu

Given this schema:

model Session {
    id                   String   @id
    expiresAt            DateTime
    token                String
    createdAt            DateTime
    updatedAt            DateTime
    ipAddress            String?
    userAgent            String?
    userId               String
    user                 User     @relation(fields: [userId], references: [id], onDelete: Cascade)
    activeOrganizationId String?

    @@schema('auth')
    @@unique([token])
    @@auth
}

I would like to be able to set the user of the @@auth model as such:

   const client = zenstackClientWithPolicies.$setAuth({
      ...session,
      user: { ... },  // <--- Type Error: user property doesn't not exist
    })

If I recall, this was possible in V2:

enhance(prisma, {
  user: {
    ...session,
    user,
  },
}),

Relevant discord discussion: https://discord.com/channels/1035538056146595961/1440320890142326926

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions