File tree Expand file tree Collapse file tree 1 file changed +3
-7
lines changed
Expand file tree Collapse file tree 1 file changed +3
-7
lines changed Original file line number Diff line number Diff line change 11import { GraphQLError } from 'graphql' ;
22
3- function calculateQueryComplexity ( document , fragments ) {
3+ function calculateQueryComplexity ( operation , fragments ) {
44 let maxDepth = 0 ;
55 let totalFields = 0 ;
66
@@ -35,11 +35,7 @@ function calculateQueryComplexity(document, fragments) {
3535 }
3636 }
3737
38- for ( const definition of document . definitions ) {
39- if ( definition . kind === 'OperationDefinition' ) {
40- visitSelectionSet ( definition . selectionSet , 0 , new Set ( ) ) ;
41- }
42- }
38+ visitSelectionSet ( operation . selectionSet , 0 , new Set ( ) ) ;
4339
4440 return { depth : maxDepth , fields : totalFields } ;
4541}
@@ -71,7 +67,7 @@ function createComplexityValidationPlugin(getConfig) {
7167 }
7268
7369 const { depth, fields } = calculateQueryComplexity (
74- requestContext . document ,
70+ requestContext . operation ,
7571 fragments
7672 ) ;
7773
You can’t perform that action at this time.
0 commit comments