Skip to content

Commit 158bfe5

Browse files
committed
docs(decorators): add info about async createParamDecorator
1 parent ddfc3ff commit 158bfe5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/custom-decorators.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,19 @@ Or might be a more advanced one that performs some calculations and encapsulates
5252

5353
```typescript
5454
function Fields(level = 1): ParameterDecorator {
55-
return createParamDecorator(({ info }) => {
55+
return createParamDecorator(async ({ info }) => {
5656
const fieldsMap: FieldsMap = {};
5757
// calculate an object with info about requested fields
5858
// based on GraphQL `info` parameter of the resolver and the level parameter
59+
60+
// or even call some async service, as it can be a regular async function and we can just `await`
5961
return fieldsMap;
6062
});
6163
}
6264
```
6365

66+
> Be aware, that async function as a custom param decorators logic can make the GraphQL resolver execution slower, so try to avoid them, if possible.
67+
6468
Then we can use our custom param decorators in the resolvers just like the built-in decorators:
6569

6670
```typescript

0 commit comments

Comments
 (0)