UNPKG

@envelop/rate-limiter

Version:

This plugins uses [`graphql-rate-limit`](https://github.com/teamplanes/graphql-rate-limit#readme) in order to limit the rate of calling queries and mutations.

21 lines (20 loc) 651 B
class InMemoryStore { // The store is mutable. // tslint:disable-next-line readonly-keyword state = {}; setForIdentity(identity, timestamps) { // tslint:disable-next-line no-object-mutation this.state = { ...this.state, [identity.contextIdentity]: { ...this.state[identity.contextIdentity], [identity.fieldIdentity]: [...timestamps], }, }; } getForIdentity(identity) { const ctxState = this.state[identity.contextIdentity]; return (ctxState && ctxState[identity.fieldIdentity]) || []; } } export { InMemoryStore };