@@ -4,7 +4,6 @@ import { isAsyncIterable } from '../jsutils/isAsyncIterable.js';
44import { isIterableObject } from '../jsutils/isIterableObject.js' ;
55import { isObjectLike } from '../jsutils/isObjectLike.js' ;
66import { isPromise } from '../jsutils/isPromise.js' ;
7- import { mapValue } from '../jsutils/mapValue.js' ;
87import type { Maybe } from '../jsutils/Maybe.js' ;
98import { memoize3 } from '../jsutils/memoize3.js' ;
109import 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' ;
@@ -119,6 +119,10 @@ const collectSubfields = memoize3(
119119 */
120120export interface ValidatedExecutionArgs {
121121 schema : GraphQLSchema ;
122+ // TODO: consider deprecating/removing fragmentDefinitions if/when fragment
123+ // arguments are officially supported and/or the full fragment details are
124+ // exposed within GraphQLResolveInfo.
125+ fragmentDefinitions : ObjMap < FragmentDefinitionNode > ;
122126 fragments : ObjMap < FragmentDetails > ;
123127 rootValue : unknown ;
124128 contextValue : unknown ;
@@ -368,6 +372,8 @@ export function validateExecutionArgs(
368372 assertValidSchema ( schema ) ;
369373
370374 let operation : OperationDefinitionNode | undefined ;
375+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
376+ Object . create ( null ) ;
371377 const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
372378 for ( const definition of document . definitions ) {
373379 switch ( definition . kind ) {
@@ -386,6 +392,7 @@ export function validateExecutionArgs(
386392 }
387393 break ;
388394 case Kind . FRAGMENT_DEFINITION : {
395+ fragmentDefinitions [ definition . name . value ] = definition ;
389396 let variableSignatures ;
390397 if ( definition . variableDefinitions ) {
391398 variableSignatures = Object . create ( null ) ;
@@ -426,6 +433,7 @@ export function validateExecutionArgs(
426433
427434 return {
428435 schema,
436+ fragmentDefinitions,
429437 fragments,
430438 rootValue,
431439 contextValue,
@@ -668,7 +676,7 @@ export function buildResolveInfo(
668676 parentType : GraphQLObjectType ,
669677 path : Path ,
670678) : GraphQLResolveInfo {
671- const { schema, fragments , rootValue, operation, variableValues } =
679+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
672680 validatedExecutionArgs ;
673681 // The resolve function's optional fourth argument is a collection of
674682 // information about the current execution state.
@@ -679,10 +687,7 @@ export function buildResolveInfo(
679687 parentType,
680688 path,
681689 schema,
682- fragments : mapValue (
683- fragments ,
684- ( fragmentDetails ) => fragmentDetails . definition ,
685- ) ,
690+ fragments : fragmentDefinitions ,
686691 rootValue,
687692 operation,
688693 variableValues,
0 commit comments