diff --git a/README.md b/README.md index 700ab128..e3c34933 100644 --- a/README.md +++ b/README.md @@ -372,6 +372,7 @@ For example: model Product { /// Old description /// @deprecated Use new name instead + /// @complexity 1 oldName String } ``` @@ -388,6 +389,7 @@ export class Product { @Field(() => String, { description: 'Old description', deprecationReason: 'Use new name instead', + complexity: 1 }) oldName: string; } diff --git a/src/helpers/object-settings.ts b/src/helpers/object-settings.ts index 535b023a..201ecbea 100644 --- a/src/helpers/object-settings.ts +++ b/src/helpers/object-settings.ts @@ -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;