How to use the graphql-rate-limit.getGraphQLRateLimiter function in graphql-rate-limit

To help you get started, we’ve selected a few graphql-rate-limit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teamplanes / graphql-rate-limit / example / index.js View on Github external
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'

graphql-rate-limit

Add Rate Limiting To Your GraphQL Resolvers 💂‍♀

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages