@@ -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 ;
@@ -478,6 +482,8 @@ export function validateExecutionArgs(
478
482
assertValidSchema ( schema ) ;
479
483
480
484
let operation : OperationDefinitionNode | undefined ;
485
+ const fragmentDefinitions : ObjMap < FragmentDefinitionNode > =
486
+ Object . create ( null ) ;
481
487
const fragments : ObjMap < FragmentDetails > = Object . create ( null ) ;
482
488
for ( const definition of document . definitions ) {
483
489
switch ( definition . kind ) {
@@ -496,6 +502,7 @@ export function validateExecutionArgs(
496
502
}
497
503
break ;
498
504
case Kind . FRAGMENT_DEFINITION : {
505
+ fragmentDefinitions [ definition . name . value ] = definition ;
499
506
let variableSignatures ;
500
507
if ( definition . variableDefinitions ) {
501
508
variableSignatures = Object . create ( null ) ;
@@ -536,6 +543,7 @@ export function validateExecutionArgs(
536
543
537
544
return {
538
545
schema,
546
+ fragmentDefinitions,
539
547
fragments,
540
548
rootValue,
541
549
contextValue,
@@ -827,7 +835,7 @@ export function buildResolveInfo(
827
835
parentType : GraphQLObjectType ,
828
836
path : Path ,
829
837
) : GraphQLResolveInfo {
830
- const { schema, fragments , rootValue, operation, variableValues } =
838
+ const { schema, fragmentDefinitions , rootValue, operation, variableValues } =
831
839
validatedExecutionArgs ;
832
840
// The resolve function's optional fourth argument is a collection of
833
841
// information about the current execution state.
@@ -838,10 +846,7 @@ export function buildResolveInfo(
838
846
parentType,
839
847
path,
840
848
schema,
841
- fragments : mapValue (
842
- fragments ,
843
- ( fragmentDetails ) => fragmentDetails . definition ,
844
- ) ,
849
+ fragments : fragmentDefinitions ,
845
850
rootValue,
846
851
operation,
847
852
variableValues,
0 commit comments