Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export function createComplexityLimitRule(
const cost = visitor.getCost();

if (onCost) {
onCost(cost);
onCost(cost, context);
}

if (cost > maxCost) {
Expand Down
8 changes: 4 additions & 4 deletions test/createComplexityLimitRule.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GraphQLError, parse, validate } from 'graphql';
import { GraphQLError, parse, validate, ValidationContext } from 'graphql';

import { createComplexityLimitRule } from '../src';

Expand Down Expand Up @@ -53,7 +53,7 @@ describe('createComplexityLimitRule', () => {
]);

expect(errors).toHaveLength(0);
expect(onCostSpy).toHaveBeenCalledWith(1);
expect(onCostSpy).toHaveBeenCalledWith(1, expect.any(ValidationContext));
});

it('should call onCost with complexity score on an SDL schema', () => {
Expand All @@ -72,7 +72,7 @@ describe('createComplexityLimitRule', () => {
]);

expect(errors).toHaveLength(0);
expect(onCostSpy).toHaveBeenCalledWith(51);
expect(onCostSpy).toHaveBeenCalledWith(51, expect.any(ValidationContext));
});

it('should call onCost with cost when there are errors', () => {
Expand All @@ -91,7 +91,7 @@ describe('createComplexityLimitRule', () => {
]);

expect(errors).toHaveLength(1);
expect(onCostSpy).toHaveBeenCalledWith(10);
expect(onCostSpy).toHaveBeenCalledWith(10, expect.any(ValidationContext));
});

it('should call formatErrorMessage with cost', () => {
Expand Down