Skip to content

Commit ef8c327

Browse files
authored
feat: Support @field() option 'complexity' through comment line
1 parent 28eb34c commit ef8c327

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ For example:
372372
model Product {
373373
/// Old description
374374
/// @deprecated Use new name instead
375+
/// @complexity 1
375376
oldName String
376377
}
377378
```
@@ -388,6 +389,7 @@ export class Product {
388389
@Field(() => String, {
389390
description: 'Old description',
390391
deprecationReason: 'Use new name instead',
392+
complexity: 1
391393
})
392394
oldName: string;
393395
}

src/helpers/object-settings.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ function createSettingElement({
184184

185185
return result;
186186
}
187+
188+
if (line.startsWith('@complexity')) {
189+
let n = Number.parseInt(trim(line.slice(11)));
190+
if(n !== n || n < 1) n = 1;
191+
fieldElement.arguments!['complexity'] = n;
192+
193+
result.element = fieldElement;
194+
195+
return result;
196+
}
187197

188198
const name = match?.groups?.name;
189199

0 commit comments

Comments
 (0)