Skip to content

index.Function.reportDenials

github-actions[bot] edited this page Nov 30, 2026 · 12 revisions

Function: reportDenials()

function reportDenials<TResult>(context, result): TResult;

Defined in: packages/graphql-casl/src/denials.ts:180

Merges the denials onDeny: 'filter' recorded for a request into its execution result — the ones the response could not carry through the denied field itself (see ApplyPermissionsOptions.onDeny).

Type Parameters

TResult

TResult extends ExecutionResult<ObjMap<unknown>, ObjMap<unknown>>

Parameters

context

unknown

The request's context value: the one the resolvers saw.

result

TResult

The execution result to report into.

Returns

TResult

The result with the denials merged in, or result itself if there were none.

Remarks

The /envelop entry point calls this for you. Under applyPermissions no hook sees the finished response, so call it from your server's own — Apollo Server's willSendResponse, or straight after execute:

const result = reportDenials(contextValue, await execute({ schema, document, contextValue }));

Under report: 'errors' the denials are appended to result.errors; under report: 'extensions' they are formatted into result.extensions.authorizationErrors. The record is drained, so a context is reported once, and a context with nothing recorded returns the result untouched. Nothing is recorded under 'reject' or 'mask'.

API Reference

Clone this wiki locally