@@ -5,7 +5,6 @@ import { isAsyncIterable } from '../jsutils/isAsyncIterable.js';
55import { isIterableObject } from '../jsutils/isIterableObject.js' ;
66import { isObjectLike } from '../jsutils/isObjectLike.js' ;
77import { isPromise } from '../jsutils/isPromise.js' ;
8- import { mapValue } from '../jsutils/mapValue.js' ;
98import type { Maybe } from '../jsutils/Maybe.js' ;
109import { memoize3 } from '../jsutils/memoize3.js' ;
1110import type { ObjMap } from '../jsutils/ObjMap.js' ;
@@ -21,6 +20,7 @@ import { locatedError } from '../error/locatedError.js';
2120import type {
2221 DocumentNode ,
2322 FieldNode ,
23+ FragmentDefinitionNode ,
2424 OperationDefinitionNode ,
2525} from '../language/ast.js' ;
2626import { OperationTypeNode } from '../language/ast.js' ;
@@ -139,6 +139,7 @@ const collectSubfields = memoize3(
139139 */
140140export interface ValidatedExecutionArgs {
141141 schema : GraphQLSchema ;
142+ fragmentDefinitions : ObjMap < FragmentDefinitionNode > ;
142143 fragments : ObjMap < FragmentDetails > ;
143144 rootValue : unknown ;
144145 contextValue : unknown ;
@@ -478,6 +479,8 @@ export function validateExecutionArgs(
478479 assertValidSchema ( schema ) ;
479480
480481 let operation : OperationDefinitionNode | undefined ;
482+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
483+ Object . create ( null ) ;
481484 const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
482485 for ( const definition of document . definitions ) {
483486 switch ( definition . kind ) {
@@ -504,6 +507,7 @@ export function validateExecutionArgs(
504507 variableSignatures [ signature . name ] = signature ;
505508 }
506509 }
510+ fragmentDefinitions [ definition . name . value ] = definition ;
507511 fragments [ definition . name . value ] = { definition, variableSignatures } ;
508512 break ;
509513 }
@@ -536,6 +540,7 @@ export function validateExecutionArgs(
536540
537541 return {
538542 schema,
543+ fragmentDefinitions,
539544 fragments,
540545 rootValue,
541546 contextValue,
@@ -827,7 +832,7 @@ export function buildResolveInfo(
827832 parentType : GraphQLObjectType ,
828833 path : Path ,
829834) : GraphQLResolveInfo {
830- const { schema, fragments , rootValue, operation, variableValues } =
835+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
831836 validatedExecutionArgs ;
832837 // The resolve function's optional fourth argument is a collection of
833838 // information about the current execution state.
@@ -838,10 +843,7 @@ export function buildResolveInfo(
838843 parentType,
839844 path,
840845 schema,
841- fragments : mapValue (
842- fragments ,
843- ( fragmentDetails ) => fragmentDetails . definition ,
844- ) ,
846+ fragments : fragmentDefinitions ,
845847 rootValue,
846848 operation,
847849 variableValues,
0 commit comments