File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -229,13 +229,16 @@ 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
234- let query : DocumentNode = parse (` ...` );
234+ 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
238- const complexity: number = queryParser .parse (query );
241+ const complexity: number = queryParser .processQuery (queryAST );
239242 ```
240243
241244### Rate- limiting
@@ -259,17 +262,15 @@ This package exposes 3 additional functionalities which comprise the internals o
259262 refillRate: 1,
260263 capacity: 10,
261264 },
262- typeWeights ,
263- true
265+ redisClient ,
266+ 86400000 // 24 hours
264267 );
265268
266269 const response: RateLimiterResponse = limiter.processRequest(
267270 'user-1',
268271 new Date().valueOf(),
269272 5
270273 );
271-
272- const complexity: number = queryParser.parse(query);
273274 ` ` `
274275
275276## < a name= " future-development" >< / a> Future Development
You can’t perform that action at this time.
0 commit comments