Skip to content

Commit

Permalink
fix: 🐛 correct store permissions for chained queries
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Oct 29, 2024
1 parent e889ff2 commit fcbd014
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/applyRuleRelationsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function getNestedQueryRelations(args: any, abilities: PureAbility<AbilityTuple,

if (relationField) {
const nestedQueryRelations = {
...getNestedQueryRelations(args[method][relation], abilities, 'read', relationField.type as Prisma.ModelName),
...getNestedQueryRelations(args[method][relation], abilities, action === 'all' ? 'all' : 'read', relationField.type as Prisma.ModelName),
...(queryRelations[relation]?.select ?? {})
}
if (nestedQueryRelations && Object.keys(nestedQueryRelations).length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,7 @@ describe('prisma extension casl', () => {
useCaslAbilities(builderFactory, { permissionField: 'casl' })
)
const result = await client.post.findUnique({ where: { id: 0 } }).author()
expect(result).toEqual({ email: '0', id: 0, casl: ['create', 'read'] })
expect(result).toEqual({ email: '0', id: 0, casl: ['create', 'read', 'update', 'delete'] })
})
})

Expand Down

0 comments on commit fcbd014

Please sign in to comment.