Skip to content

Commit

Permalink
fix: 🐛 correct get abilities function
Browse files Browse the repository at this point in the history
  • Loading branch information
dennemark committed Aug 9, 2024
1 parent 98f66ba commit a3469fd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ export function useCaslAbilities(getAbilityFactory: () => AbilityBuilder<PureAbi
// alter the getAblities function shortly
getAbilities = () => extendFactory(getAbilityFactory())
return ctx as CaslExtensionType

}
},
query: {
$allModels: {
async $allOperations<T>({ args, query, model, operation, extendRules, ...rest }: { args: any, query: any, model: any, operation: any, extendRules?: (factory: AbilityBuilder<PureAbility<AbilityTuple, PrismaQuery>>) => AbilityBuilder<PureAbility<AbilityTuple, PrismaQuery>> }) {
async $allOperations<T>({ args, query, model, operation, ...rest }: { args: any, query: any, model: any, operation: any }) {
const debug = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test' && args.debugCasl
delete args.debugCasl
const perf = debug ? performance : undefined
Expand All @@ -77,7 +76,7 @@ export function useCaslAbilities(getAbilityFactory: () => AbilityBuilder<PureAbi

perf?.mark('prisma-casl-extension-0')

const abilities = extendRules ? extendRules(getAbilityFactory()).build() : getAbilityFactory().build()
const abilities = getAbilities().build()
// reset alteration of getAblities function
getAbilities = () => getAbilityFactory()
perf?.mark('prisma-casl-extension-1')
Expand Down

0 comments on commit a3469fd

Please sign in to comment.