File tree Expand file tree Collapse file tree 1 file changed +1
-12
lines changed Expand file tree Collapse file tree 1 file changed +1
-12
lines changed Original file line number Diff line number Diff line change @@ -59,24 +59,13 @@ export default class QueryComplexity {
5959 this . context = context ;
6060 this . complexity = 0 ;
6161 this . options = options ;
62- this . fragments = this . getFragments ( context ) ;
6362
6463 this . OperationDefinition = {
6564 enter : this . onOperationDefinitionEnter ,
6665 leave : this . onOperationDefinitionLeave
6766 } ;
6867 }
6968
70- getFragments ( context : ValidationContext ) : { [ name : string ] : FragmentDefinitionNode } {
71- return context . getDocument ( ) . definitions . reduce ( ( map , definition ) => {
72- if ( definition . kind === Kind . FRAGMENT_DEFINITION ) {
73- map [ definition . name . value ] = definition ;
74- }
75-
76- return map ;
77- } , { } ) ;
78- }
79-
8069 onOperationDefinitionEnter ( operation : OperationDefinitionNode ) {
8170 switch ( operation . operation ) {
8271 case 'query' :
@@ -166,7 +155,7 @@ export default class QueryComplexity {
166155 break ;
167156 }
168157 case Kind . FRAGMENT_SPREAD : {
169- const fragment = this . fragments [ childNode . name . value ] ;
158+ const fragment = this . context . getFragment ( childNode . name . value ) ;
170159 const fragmentType = this . context . getSchema ( ) . getType ( fragment . typeCondition . name . value ) ;
171160 nodeComplexity = this . nodeComplexity ( fragment , fragmentType ) ;
172161 break ;
You can’t perform that action at this time.
0 commit comments