@@ -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 ;
@@ -492,6 +496,8 @@ export function validateExecutionArgs(
492496 assertValidSchema ( schema ) ;
493497
494498 let operation : OperationDefinitionNode | undefined ;
499+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
500+ Object . create ( null ) ;
495501 const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
496502 for ( const definition of document . definitions ) {
497503 switch ( definition . kind ) {
@@ -510,6 +516,7 @@ export function validateExecutionArgs(
510516 }
511517 break ;
512518 case Kind . FRAGMENT_DEFINITION : {
519+ fragmentDefinitions [ definition . name . value ] = definition ;
513520 let variableSignatures ;
514521 if ( definition . variableDefinitions ) {
515522 variableSignatures = Object . create ( null ) ;
@@ -550,6 +557,7 @@ export function validateExecutionArgs(
550557
551558 return {
552559 schema,
560+ fragmentDefinitions,
553561 fragments,
554562 rootValue,
555563 contextValue,
@@ -842,7 +850,7 @@ export function buildResolveInfo(
842850 parentType : GraphQLObjectType ,
843851 path : Path ,
844852) : GraphQLResolveInfo {
845- const { schema, fragments , rootValue, operation, variableValues } =
853+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
846854 validatedExecutionArgs ;
847855 // The resolve function's optional fourth argument is a collection of
848856 // information about the current execution state.
@@ -853,10 +861,7 @@ export function buildResolveInfo(
853861 parentType,
854862 path,
855863 schema,
856- fragments : mapValue (
857- fragments ,
858- ( fragmentDetails ) => fragmentDetails . definition ,
859- ) ,
864+ fragments : fragmentDefinitions ,
860865 rootValue,
861866 operation,
862867 variableValues,
0 commit comments