File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Authentication
2
+
3
+ Authentication can be used as a guard on a field, query or mutation, restricting data access or actions for a specific group of users.
4
+
5
+ Since the codebase uses TypeGraphQL, which relies heavily on decorators, authentication is also done using decorators.
6
+
7
+ Authentication is done with use of ` @Permission ` decorator. This decorator takes function as an argument with permission object as a return value.
8
+
9
+ For example:
10
+
11
+ ``` lang=js
12
+ @Permission(async (resolverData) => ({
13
+ or: [
14
+ {
15
+ type: 'global',
16
+ permission: 'viewOperationMetadata',
17
+ },
18
+ {
19
+ type: 'operation',
20
+ permission: 'canViewMetadata',
21
+ id: 11,
22
+ },
23
+ ],
24
+ }))
25
+ ```
26
+
27
+ In this example, ` id ` field is hardcoded for demo purposes, but ` resolverData ` can be used to obtain the actual value.
You can’t perform that action at this time.
0 commit comments