Skip to content

Commit

Permalink
πŸ“ Document auth decorators usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Pl217 committed Nov 2, 2021
1 parent 004a6d4 commit 837c278
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/AUTH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Authentication

Authentication can be used as a guard on a field, query or mutation, restricting data access or actions for a specific group of users.

Since the codebase uses TypeGraphQL, which relies heavily on decorators, authentication is also done using decorators.

Authentication is done with use of `@Permission` decorator. This decorator takes function as an argument with permission object as a return value.

For example:

```lang=js
@Permission(async (resolverData) => ({
or: [
{
type: 'global',
permission: 'viewOperationMetadata',
},
{
type: 'operation',
permission: 'canViewMetadata',
id: 11,
},
],
}))
```

In this example, `id` field is hardcoded for demo purposes, but `resolverData` can be used to obtain the actual value.

0 comments on commit 837c278

Please sign in to comment.