@graphql-mesh/plugin-rate-limit 0.103.20 → 0.103.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +2 -2
- package/esm/index.js +2 -2
- package/package.json +4 -3
package/cjs/index.js
CHANGED
|
@@ -4,14 +4,14 @@ exports.default = useMeshRateLimit;
|
|
|
4
4
|
const rate_limiter_1 = require("@envelop/rate-limiter");
|
|
5
5
|
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
6
6
|
const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
|
|
7
|
-
const
|
|
7
|
+
const promise_helpers_1 = require("@whatwg-node/promise-helpers");
|
|
8
8
|
class RateLimitMeshStore extends rate_limiter_1.Store {
|
|
9
9
|
constructor(cache) {
|
|
10
10
|
super();
|
|
11
11
|
this.cache = cache;
|
|
12
12
|
}
|
|
13
13
|
getForIdentity(identity) {
|
|
14
|
-
return (0,
|
|
14
|
+
return (0, promise_helpers_1.handleMaybePromise)(() => this.cache.get(`rate-limit:${identity.contextIdentity}:${identity.fieldIdentity}`), value => value || []);
|
|
15
15
|
}
|
|
16
16
|
setForIdentity(identity, timestamps, windowMs) {
|
|
17
17
|
return this.cache.set(`rate-limit:${identity.contextIdentity}:${identity.fieldIdentity}`, timestamps, { ttl: windowMs / 1000 });
|
package/esm/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Store, useRateLimiter } from '@envelop/rate-limiter';
|
|
2
2
|
import { process } from '@graphql-mesh/cross-helpers';
|
|
3
3
|
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
4
|
-
import {
|
|
4
|
+
import { handleMaybePromise } from '@whatwg-node/promise-helpers';
|
|
5
5
|
class RateLimitMeshStore extends Store {
|
|
6
6
|
constructor(cache) {
|
|
7
7
|
super();
|
|
8
8
|
this.cache = cache;
|
|
9
9
|
}
|
|
10
10
|
getForIdentity(identity) {
|
|
11
|
-
return
|
|
11
|
+
return handleMaybePromise(() => this.cache.get(`rate-limit:${identity.contextIdentity}:${identity.fieldIdentity}`), value => value || []);
|
|
12
12
|
}
|
|
13
13
|
setForIdentity(identity, timestamps, windowMs) {
|
|
14
14
|
return this.cache.set(`rate-limit:${identity.contextIdentity}:${identity.fieldIdentity}`, timestamps, { ttl: windowMs / 1000 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-rate-limit",
|
|
3
|
-
"version": "0.103.
|
|
3
|
+
"version": "0.103.21",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"@envelop/rate-limiter": "^7.0.1",
|
|
10
10
|
"@graphql-mesh/cross-helpers": "^0.4.10",
|
|
11
11
|
"@graphql-mesh/string-interpolation": "0.5.8",
|
|
12
|
-
"@graphql-mesh/types": "^0.103.
|
|
13
|
-
"@graphql-mesh/utils": "^0.103.
|
|
12
|
+
"@graphql-mesh/types": "^0.103.20",
|
|
13
|
+
"@graphql-mesh/utils": "^0.103.20",
|
|
14
14
|
"@graphql-tools/utils": "^10.8.0",
|
|
15
|
+
"@whatwg-node/promise-helpers": "^1.0.0",
|
|
15
16
|
"tslib": "^2.4.0"
|
|
16
17
|
},
|
|
17
18
|
"repository": {
|