@@ -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 ;
@@ -329,6 +333,8 @@ export function validateExecutionArgs(
329333 assertValidSchema ( schema ) ;
330334
331335 let operation : OperationDefinitionNode | undefined ;
336+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
337+ Object . create ( null ) ;
332338 const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
333339 for ( const definition of document . definitions ) {
334340 switch ( definition . kind ) {
@@ -347,6 +353,7 @@ export function validateExecutionArgs(
347353 }
348354 break ;
349355 case Kind . FRAGMENT_DEFINITION : {
356+ fragmentDefinitions [ definition . name . value ] = definition ;
350357 let variableSignatures ;
351358 if ( definition . variableDefinitions ) {
352359 variableSignatures = Object . create ( null ) ;
@@ -387,6 +394,7 @@ export function validateExecutionArgs(
387394
388395 return {
389396 schema,
397+ fragmentDefinitions,
390398 fragments,
391399 rootValue,
392400 contextValue,
@@ -622,7 +630,7 @@ export function buildResolveInfo(
622630 parentType : GraphQLObjectType ,
623631 path : Path ,
624632) : GraphQLResolveInfo {
625- const { schema, fragments , rootValue, operation, variableValues } =
633+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
626634 validatedExecutionArgs ;
627635 // The resolve function's optional fourth argument is a collection of
628636 // information about the current execution state.
@@ -633,10 +641,7 @@ export function buildResolveInfo(
633641 parentType,
634642 path,
635643 schema,
636- fragments : mapValue (
637- fragments ,
638- ( fragmentDetails ) => fragmentDetails . definition ,
639- ) ,
644+ fragments : fragmentDefinitions ,
640645 rootValue,
641646 operation,
642647 variableValues,
0 commit comments