Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
identifyContext: context => {
return context.req.ip;
}
});
const permissions = shield({
Query: {
myId: rateLimit({
max: 2,
window: '10s'
})
}
});
// Option 3: Manually use the rate limiter in resolvers
const rateLimiter = getGraphQLRateLimiter({
formatError: () => {
return 'Stop doing that.';
},
identifyContext: context => {
return context.req.ip;
}
});
const books = [
{
title: 'Harry Potter and the Chamber of Secrets',
author: 'J.K. Rowling'
},
{
title: 'Jurassic Park',
author: 'Michael Crichton'