How to use the graphql-rate-limit-directive.createRateLimitTypeDef function in graphql-rate-limit-directive

To help you get started, we’ve selected a few graphql-rate-limit-directive 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 ravangen / graphql-rate-limit / examples / multiple / index.js View on Github external
},
      {
        title: 'The Hobbit',
        author: 'J. R. R. Tolkien',
      },
    ],
    quote: () =>
      'The future is something which everyone reaches at the rate of sixty minutes an hour, whatever he does, whoever he is. ― C.S. Lewis',
  },
};

const server = new ApolloServer({
  // IMPORTANT: Include directive type definitions for both @burstRateLimit and @sustainedRateLimit
  typeDefs: [
    createRateLimitTypeDef('burstRateLimit'),
    createRateLimitTypeDef('sustainedRateLimit'),
    typeDefs,
  ],
  resolvers,
  schemaDirectives: {
    // IMPORTANT: Include directive implementations (directive name is determined by the key)
    burstRateLimit: createRateLimitDirective(),
    sustainedRateLimit: createRateLimitDirective(),
  },
});
server
  .listen()
  .then(({ url }) => {
    console.log(`πŸš€  Server ready at ${url}`);
  })
  .catch(error => {
    console.error(error);
github ravangen / graphql-rate-limit / examples / multiple / index.js View on Github external
author: 'George R. R. Martin',
      },
      {
        title: 'The Hobbit',
        author: 'J. R. R. Tolkien',
      },
    ],
    quote: () =>
      'The future is something which everyone reaches at the rate of sixty minutes an hour, whatever he does, whoever he is. ― C.S. Lewis',
  },
};

const server = new ApolloServer({
  // IMPORTANT: Include directive type definitions for both @burstRateLimit and @sustainedRateLimit
  typeDefs: [
    createRateLimitTypeDef('burstRateLimit'),
    createRateLimitTypeDef('sustainedRateLimit'),
    typeDefs,
  ],
  resolvers,
  schemaDirectives: {
    // IMPORTANT: Include directive implementations (directive name is determined by the key)
    burstRateLimit: createRateLimitDirective(),
    sustainedRateLimit: createRateLimitDirective(),
  },
});
server
  .listen()
  .then(({ url }) => {
    console.log(`πŸš€  Server ready at ${url}`);
  })
  .catch(error => {

graphql-rate-limit-directive

Fixed window rate-limiting directive for GraphQL. Use to limit repeated requests to queries and mutations.

MIT
Latest version published 7 months ago

Package Health Score

66 / 100
Full package analysis