@@ -5,7 +5,6 @@ import { isAsyncIterable } from '../jsutils/isAsyncIterable.js';
5
5
import { isIterableObject } from '../jsutils/isIterableObject.js' ;
6
6
import { isObjectLike } from '../jsutils/isObjectLike.js' ;
7
7
import { isPromise } from '../jsutils/isPromise.js' ;
8
- import { mapValue } from '../jsutils/mapValue.js' ;
9
8
import type { Maybe } from '../jsutils/Maybe.js' ;
10
9
import { memoize3 } from '../jsutils/memoize3.js' ;
11
10
import type { ObjMap } from '../jsutils/ObjMap.js' ;
@@ -21,6 +20,7 @@ import { locatedError } from '../error/locatedError.js';
21
20
import type {
22
21
DocumentNode ,
23
22
FieldNode ,
23
+ FragmentDefinitionNode ,
24
24
OperationDefinitionNode ,
25
25
} from '../language/ast.js' ;
26
26
import { OperationTypeNode } from '../language/ast.js' ;
@@ -139,6 +139,10 @@ const collectSubfields = memoize3(
139
139
*/
140
140
export interface ValidatedExecutionArgs {
141
141
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 > ;
142
146
fragments : ObjMap < FragmentDetails > ;
143
147
rootValue : unknown ;
144
148
contextValue : unknown ;
@@ -492,6 +496,8 @@ export function validateExecutionArgs(
492
496
assertValidSchema ( schema ) ;
493
497
494
498
let operation : OperationDefinitionNode | undefined ;
499
+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
500
+ Object . create ( null ) ;
495
501
const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
496
502
for ( const definition of document . definitions ) {
497
503
switch ( definition . kind ) {
@@ -510,6 +516,7 @@ export function validateExecutionArgs(
510
516
}
511
517
break ;
512
518
case Kind . FRAGMENT_DEFINITION : {
519
+ fragmentDefinitions [ definition . name . value ] = definition ;
513
520
let variableSignatures ;
514
521
if ( definition . variableDefinitions ) {
515
522
variableSignatures = Object . create ( null ) ;
@@ -550,6 +557,7 @@ export function validateExecutionArgs(
550
557
551
558
return {
552
559
schema,
560
+ fragmentDefinitions,
553
561
fragments,
554
562
rootValue,
555
563
contextValue,
@@ -842,7 +850,7 @@ export function buildResolveInfo(
842
850
parentType : GraphQLObjectType ,
843
851
path : Path ,
844
852
) : GraphQLResolveInfo {
845
- const { schema, fragments , rootValue, operation, variableValues } =
853
+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
846
854
validatedExecutionArgs ;
847
855
// The resolve function's optional fourth argument is a collection of
848
856
// information about the current execution state.
@@ -853,10 +861,7 @@ export function buildResolveInfo(
853
861
parentType,
854
862
path,
855
863
schema,
856
- fragments : mapValue (
857
- fragments ,
858
- ( fragmentDetails ) => fragmentDetails . definition ,
859
- ) ,
864
+ fragments : fragmentDefinitions ,
860
865
rootValue,
861
866
operation,
862
867
variableValues,
0 commit comments