Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 879a4cb

Browse files
Merge branch 'em/finalDeploy' of https://github.com/oslabs-beta/GraphQL-Gate into em/finalDeploy
2 parents 4822276 + fbe4e57 commit 879a4cb

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

‎README.md‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /