Skip to content

Commit

Permalink
feat: Support @field() option 'complexity' through comment line
Browse files Browse the repository at this point in the history
  • Loading branch information
tatoBr authored Jan 18, 2025
1 parent 28eb34c commit ef8c327
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ For example:
model Product {
/// Old description
/// @deprecated Use new name instead
/// @complexity 1
oldName String
}
```
Expand All @@ -388,6 +389,7 @@ export class Product {
@Field(() => String, {
description: 'Old description',
deprecationReason: 'Use new name instead',
complexity: 1
})
oldName: string;
}
Expand Down
10 changes: 10 additions & 0 deletions src/helpers/object-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ function createSettingElement({

return result;
}

if (line.startsWith('@complexity')) {
let n = Number.parseInt(trim(line.slice(11)));
if(n !== n || n < 1) n = 1;
fieldElement.arguments!['complexity'] = n;

result.element = fieldElement;

return result;
}

const name = match?.groups?.name;

Expand Down

0 comments on commit ef8c327

Please sign in to comment.