This example illustrates customizing how many points are consumed in different resolver situations.
Specify a pointsCalculator
function which uses contextual information from the resolver's info
and context
.
yarn install
node index.js
Navigate to http://localhost:4000/graphql
in a browser.
Server is configured to allow the following queries:
quote
: 10 times every 30 seconds (due todefaultPointsCalculator
)books
: 5 times every 30 seconds (due to cost of2
) or unlimited times when the GraphQL API endpoint includes query stringtoken=secret
(e.g.http://localhost:4000/graphql?token=secret
)
Sample query:
{
quote
books {
title
author
}
}