Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const pointsCalculator = (directiveArgs, obj, args, context, info) => {
// If a specific resolver for a type and field, use custom logic
if (info.parentType.name === 'Query' && info.fieldName === 'books') {
// When query string `token=secret` is used, allow unlimited usage, else costs 2 for `books`
return context.query && context.query.token === 'secret' ? 0 : 2;
} else {
return defaultPointsCalculator(directiveArgs, obj, args, context, info);
}
};