-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUESTION]: Reset attempts #370
Comments
Hi, thank you for your question! It is not currently possible, but it seems reasonable. I think it could be achieved via a callback. Currently the limiter only does work before the resolve action, but could also have an optional after action callable (likely only called on success?). function onResolve(limiter, key, points, result) {
// Your custom logic based on result
limiter.reward(key, points);
return result; // outcome of the original resolve (could transform if needed)
}
const resolvers = {
Query: {
quote: {
resolve: () =>
'The future is something which everyone reaches at the rate of sixty minutes an hour, whatever he does, whoever he is. ― C.S. Lewis',
extensions: {
// IMPORTANT: Specify any overrides via field's extensions under directive's name
[directiveName]: {
onResolve: onResolve,
}
}
},
},
}; Rate limiter wraps I can try to put together something to this effect in the next week. At some point, you may want your own rate limiter within a resolver instead of a general purpose one. |
What do you mean by:
Would you suggest we build our own specific one based on example libraries such as this one? I do agree that a general one makes it difficult to customize per resolver. |
Ah, I also forgot to ask, how would we be able to reset an attempt if such a feature was implemented? |
This library builds on top of I think a callback is reasonable feature to add, but this library won't necessarily cover 100% of all custom cases.. |
Thanks I will take a look at the library you mentioned. |
Hi,
I was wondering if it was possible to reset the attempts from a mutation.
For example, I have a rate limit on a login mutation.
I would like to be able to reset the attempts when a reset password is called. (if applicable).
I am going through the doc to see how I could achieve this but I don't see a clear path yet.
Thanks!
The text was updated successfully, but these errors were encountered: