@@ -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,10 @@ const collectSubfields = memoize3(
139139 */
140140export interface ValidatedExecutionArgs {
141141 schema : GraphQLSchema ;
142+ // TODO: consider deprecating/removing fragmentDefinitions if/when fragment
143+ // arguments are officially supported and/or the full fragment details are
144+ // exposed within GraphQLResolveInfo.
145+ fragmentDefinitions : ObjMap < FragmentDefinitionNode > ;
142146 fragments : ObjMap < FragmentDetails > ;
143147 rootValue : unknown ;
144148 contextValue : unknown ;
@@ -478,6 +482,8 @@ export function validateExecutionArgs(
478482 assertValidSchema ( schema ) ;
479483
480484 let operation : OperationDefinitionNode | undefined ;
485+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
486+ Object . create ( null ) ;
481487 const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
482488 for ( const definition of document . definitions ) {
483489 switch ( definition . kind ) {
@@ -496,6 +502,7 @@ export function validateExecutionArgs(
496502 }
497503 break ;
498504 case Kind . FRAGMENT_DEFINITION : {
505+ fragmentDefinitions [ definition . name . value ] = definition ;
499506 let variableSignatures ;
500507 if ( definition . variableDefinitions ) {
501508 variableSignatures = Object . create ( null ) ;
@@ -536,6 +543,7 @@ export function validateExecutionArgs(
536543
537544 return {
538545 schema,
546+ fragmentDefinitions,
539547 fragments,
540548 rootValue,
541549 contextValue,
@@ -827,7 +835,7 @@ export function buildResolveInfo(
827835 parentType : GraphQLObjectType ,
828836 path : Path ,
829837) : GraphQLResolveInfo {
830- const { schema, fragments , rootValue, operation, variableValues } =
838+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
831839 validatedExecutionArgs ;
832840 // The resolve function's optional fourth argument is a collection of
833841 // information about the current execution state.
@@ -838,10 +846,7 @@ export function buildResolveInfo(
838846 parentType,
839847 path,
840848 schema,
841- fragments : mapValue (
842- fragments ,
843- ( fragmentDetails ) => fragmentDetails . definition ,
844- ) ,
849+ fragments : fragmentDefinitions ,
845850 rootValue,
846851 operation,
847852 variableValues,
0 commit comments