This example illustrates applying multiple rate limits on the same field.
Multiple limits can be used if you want to impose both burst throttling rates, and sustained throttling rates. For example, you might want to limit a user to a maximum of 60 requests per minute, and 1000 requests per day.
Multiple schema directives can be created using different names and assigned to the same location.
As of the June 2018 version of the GraphQL specification, Directives Are Unique Per Location. In newer versions of the spec, being unique per location is no longer required. However, this library continues to assume there not multiple rate limit directives with the same name on the same field.
yarn install
node index.js
Navigate to http://localhost:4000/graphql
in a browser.
Server is configured to allow each root field to be queried once every 15 seconds and three times every 60 seconds. Sample query:
{
quote
books {
title
author
}
}