@@ -5,7 +5,6 @@ import { isAsyncIterable } from '../jsutils/isAsyncIterable.js';
5
5
import { isIterableObject } from '../jsutils/isIterableObject.js' ;
6
6
import { isObjectLike } from '../jsutils/isObjectLike.js' ;
7
7
import { isPromise } from '../jsutils/isPromise.js' ;
8
- import { mapValue } from '../jsutils/mapValue.js' ;
9
8
import type { Maybe } from '../jsutils/Maybe.js' ;
10
9
import { memoize3 } from '../jsutils/memoize3.js' ;
11
10
import type { ObjMap } from '../jsutils/ObjMap.js' ;
@@ -21,6 +20,7 @@ import { locatedError } from '../error/locatedError.js';
21
20
import type {
22
21
DocumentNode ,
23
22
FieldNode ,
23
+ FragmentDefinitionNode ,
24
24
OperationDefinitionNode ,
25
25
} from '../language/ast.js' ;
26
26
import { OperationTypeNode } from '../language/ast.js' ;
@@ -139,6 +139,7 @@ const collectSubfields = memoize3(
139
139
*/
140
140
export interface ValidatedExecutionArgs {
141
141
schema : GraphQLSchema ;
142
+ fragmentDefinitions : ObjMap < FragmentDefinitionNode > ;
142
143
fragments : ObjMap < FragmentDetails > ;
143
144
rootValue : unknown ;
144
145
contextValue : unknown ;
@@ -478,6 +479,8 @@ export function validateExecutionArgs(
478
479
assertValidSchema ( schema ) ;
479
480
480
481
let operation : OperationDefinitionNode | undefined ;
482
+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
483
+ Object . create ( null ) ;
481
484
const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
482
485
for ( const definition of document . definitions ) {
483
486
switch ( definition . kind ) {
@@ -504,6 +507,7 @@ export function validateExecutionArgs(
504
507
variableSignatures [ signature . name ] = signature ;
505
508
}
506
509
}
510
+ fragmentDefinitions [ definition . name . value ] = definition ;
507
511
fragments [ definition . name . value ] = { definition, variableSignatures } ;
508
512
break ;
509
513
}
@@ -536,6 +540,7 @@ export function validateExecutionArgs(
536
540
537
541
return {
538
542
schema,
543
+ fragmentDefinitions,
539
544
fragments,
540
545
rootValue,
541
546
contextValue,
@@ -827,7 +832,7 @@ export function buildResolveInfo(
827
832
parentType : GraphQLObjectType ,
828
833
path : Path ,
829
834
) : GraphQLResolveInfo {
830
- const { schema, fragments , rootValue, operation, variableValues } =
835
+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
831
836
validatedExecutionArgs ;
832
837
// The resolve function's optional fourth argument is a collection of
833
838
// information about the current execution state.
@@ -838,10 +843,7 @@ export function buildResolveInfo(
838
843
parentType,
839
844
path,
840
845
schema,
841
- fragments : mapValue (
842
- fragments ,
843
- ( fragmentDetails ) => fragmentDetails . definition ,
844
- ) ,
846
+ fragments : fragmentDefinitions ,
845
847
rootValue,
846
848
operation,
847
849
variableValues,
0 commit comments