Skip to content

Commit fbe4e57

Browse files
authored
Update README.md
update complexity analysis with validation check
1 parent 52ba554 commit fbe4e57

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,14 @@ This package exposes 3 additional functionalities which comprise the internals o
229229

230230
```ts
231231
import { typeWeightsFromSchema } from 'graphql-limiter';
232-
import { parse } from 'graphql';
232+
import { parse, validate } from 'graphql';
233233

234234
let queryAST: DocumentNode = parse(`...`);
235235

236236
const queryParser: ASTParser = new ComplexityAnalysis(typeWeights, variables);
237+
238+
// query must be validatied against the schema before processing the query
239+
const validationErrors = validate(schema, queryAST);
237240

238241
const complexity: number = queryParser.processQuery(queryAST);
239242
```

0 commit comments

Comments
 (0)