Decorators

Decorators

Allow

Attatches metadata to the resolver defining which permissions are required to execute the operation, using one or more Permission values.

Example

 @Allow(Permission.SuperAdmin)
 @Query()
 getAdministrators() {
     // ...
 }

Api

Resolver param decorator which returns which Api the request came though. This is useful because sometimes the same resolver will have different behaviour depending whether it is being called from the shop API or the admin API.

Returns a string of type ApiType.

Example

 @Query()
 getAdministrators(@Api() apiType: ApiType) {
     if (apiType === 'admin') {
         // ...
     }
 }

Ctx

Resolver param decorator which extracts the RequestContext from the incoming request object.

Example

 @Query()
 getAdministrators(@Ctx() ctx: RequestContext) {
     // ...
 }