Skip to content

policy errors with polymorphic models #1770

@j0rdanba1n

Description

@j0rdanba1n

My zmodels are:

abstract model BaseAuth {
    id             String        @id @default(uuid())
    dateCreated    DateTime      @default(now())
    dateUpdated    DateTime      @updatedAt @default(now())

    organizationId String?
    organization   Organization? @relation(fields: [organizationId], references: [id], name: "organization")

    @@allow('all', organization.users?[user == auth()])
}

enum ResourceType {
    Personnel
}

model Resource extends BaseAuth {
    name     String?
    type     ResourceType?
    costRate Int?

    budgets  ResourceBudget[]

    @@delegate(type)
}

model Personnel extends Resource {
}

I get this error when trying to query a resource:

Invalid `prisma.resource.findMany()` invocation:

{
  where: {
    OR: [
      {
        OR: [
          {
            organization: {
              users: {
                some: {
                  user: {
                    is: {
                      id: "553a6c87-3a77-475b-8f56-f5fb59f92630"
                    }
                  }
                }
              }
            }
          }
        ]
      }
    ]
  },
  include: {
    delegate_aux_personnel: {
      where: {
        OR: [
          {
            OR: [
              {
                organization: {
                  users: {
                    some: {
                      user: {
                        is: {
                          id: "553a6c87-3a77-475b-8f56-f5fb59f92630"
                        }
                      }
                    }
                  }
                }
              }
            ]
          }
        ]
      },
      include: {
        delegate_aux_resource: {}
      }
    }
  }
}

Unknown argument `organization`. Available options are marked with ?.

Originally posted by @j0rdanba1n in #1734 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions