@@ -2,10 +2,12 @@ import {
2
2
BatchingOptions ,
3
3
delegateToSchema ,
4
4
extractUnavailableFieldsFromSelectionSet ,
5
+ FIELD_SUBSCHEMA_MAP_SYMBOL ,
5
6
getTypeInfo ,
6
7
isExternalObject ,
7
8
MergedFieldConfig ,
8
9
MergedTypeConfig ,
10
+ OBJECT_SUBSCHEMA_SYMBOL ,
9
11
SubschemaConfig ,
10
12
subtractSelectionSets ,
11
13
Transform ,
@@ -1241,7 +1243,7 @@ export function getStitchingOptionsFromSupergraphSdl(
1241
1243
if ( operationType ) {
1242
1244
const defaultMergedField = defaultMerger ( candidates ) ;
1243
1245
const mergedResolver : GraphQLFieldResolver < { } , { } > =
1244
- function mergedResolver ( _root , _args , context , info ) {
1246
+ function mergedResolver ( _root , args , context , info ) {
1245
1247
const originalSelectionSet : SelectionSetNode = {
1246
1248
kind : Kind . SELECTION_SET ,
1247
1249
selections : info . fieldNodes ,
@@ -1339,6 +1341,7 @@ export function getStitchingOptionsFromSupergraphSdl(
1339
1341
rootTypeMap . get ( info . parentType . name ) ||
1340
1342
( 'query' as OperationTypeNode ) ,
1341
1343
context,
1344
+ args,
1342
1345
info : currentFriendSubschemas ?. size
1343
1346
? {
1344
1347
...info ,
@@ -1367,6 +1370,7 @@ export function getStitchingOptionsFromSupergraphSdl(
1367
1370
rootTypeMap . get ( info . parentType . name ) ||
1368
1371
( 'query' as OperationTypeNode ) ,
1369
1372
context,
1373
+ args,
1370
1374
info : {
1371
1375
...info ,
1372
1376
fieldNodes : friendSelectionSet . selections as FieldNode [ ] ,
@@ -1676,11 +1680,26 @@ function mergeResults(results: unknown[], getFieldNames: () => Set<string>) {
1676
1680
if ( datas . length === 1 ) {
1677
1681
return makeExternalObject ( datas [ 0 ] , errors , getFieldNames ) ;
1678
1682
}
1679
- return makeExternalObject (
1680
- mergeDeep ( datas , undefined , true , true ) ,
1681
- errors ,
1682
- getFieldNames ,
1683
- ) ;
1683
+ const mergedData = mergeDeep ( datas , undefined , true , true ) ;
1684
+ // Put original symbols on the merged object
1685
+ const symbols = [
1686
+ OBJECT_SUBSCHEMA_SYMBOL ,
1687
+ FIELD_SUBSCHEMA_MAP_SYMBOL ,
1688
+ UNPATHED_ERRORS_SYMBOL ,
1689
+ ] ;
1690
+ for ( const symbol of symbols ) {
1691
+ if ( mergedData ?. [ symbol ] == null ) {
1692
+ for ( const data of datas ) {
1693
+ // @ts -expect-error - we know it is there
1694
+ const symbolValue = data ?. [ symbol ] ;
1695
+ if ( symbolValue != null ) {
1696
+ mergedData [ symbol ] = symbolValue ;
1697
+ break ;
1698
+ }
1699
+ }
1700
+ }
1701
+ }
1702
+ return makeExternalObject ( mergedData , errors , getFieldNames ) ;
1684
1703
}
1685
1704
if ( errors . length ) {
1686
1705
if ( errors . length === 1 ) {
0 commit comments