Skip to content

Commit 7dc8688

Browse files
committed
fix type issues
1 parent 6c57de1 commit 7dc8688

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

packages/delegate/src/mergeFields.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,16 @@ function handleResolverResult(
117117
const type = schema.getType(object.__typename) as GraphQLObjectType;
118118
const { fields } = collectFields(schema, EMPTY_OBJECT, EMPTY_OBJECT, type, selectionSet);
119119
const nullResult: Record<string, any> = {};
120-
for (const [responseKey, fieldNodes] of fields) {
120+
for (const [responseKey, fieldGroups] of fields) {
121121
const combinedPath = [...path, responseKey];
122122
if (resolverResult instanceof GraphQLError) {
123123
nullResult[responseKey] = relocatedError(resolverResult, combinedPath);
124124
} else if (resolverResult instanceof Error) {
125-
nullResult[responseKey] = locatedError(resolverResult, fieldNodes, combinedPath);
125+
nullResult[responseKey] = locatedError(
126+
resolverResult,
127+
fieldGroups.map(group => group.fieldNode),
128+
combinedPath,
129+
);
126130
} else {
127131
nullResult[responseKey] = null;
128132
}

packages/stitch/src/executor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export function createStitchingExecutor(stitchedSchema: GraphQLSchema) {
3232
operation.selectionSet,
3333
);
3434
const data: Record<string, any> = {};
35-
for (const [fieldName, fieldNodes] of fields) {
36-
const responseKey = fieldNodes[0].alias?.value ?? fieldName;
35+
for (const [fieldName, fieldGroups] of fields) {
36+
const responseKey = fieldGroups[0].fieldNode.alias?.value ?? fieldName;
3737
const subschemaForField = subschemas.find(subschema => {
3838
const subschemaSchema = isSubschemaConfig(subschema)
3939
? subschema.schema
@@ -48,7 +48,7 @@ export function createStitchingExecutor(stitchedSchema: GraphQLSchema) {
4848
info: {
4949
schema: stitchedSchema,
5050
fieldName,
51-
fieldNodes,
51+
fieldNodes: fieldGroups.map(group => group.fieldNode),
5252
operation,
5353
fragments,
5454
parentType: rootType,

packages/stitch/src/getFieldsNotInSubschema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export function getFieldsNotInSubschema(
2525
const fields = subschemaType.getFields();
2626

2727
const fieldsNotInSchema = new Set<FieldNode>();
28-
for (const [, subFieldNodes] of subFieldNodesByResponseKey) {
29-
const fieldName = subFieldNodes[0].name.value;
28+
for (const [, subFieldGroups] of subFieldNodesByResponseKey) {
29+
const fieldName = subFieldGroups[0].fieldNode.name.value;
3030
if (!fields[fieldName]) {
31-
for (const subFieldNode of subFieldNodes) {
32-
fieldsNotInSchema.add(subFieldNode);
31+
for (const subFieldNode of subFieldGroups) {
32+
fieldsNotInSchema.add(subFieldNode.fieldNode);
3333
}
3434
}
3535
const fieldNodesForField = fieldNodesByField?.[gatewayType.name]?.[fieldName];

packages/stitch/src/stitchingInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ export function completeStitchingInfo<TContext = Record<string, any>>(
318318
const { fields } = collectFields(schema, fragments, variableValues, type, selectionSet);
319319

320320
for (const [, fieldNodes] of fields) {
321-
for (const fieldNode of fieldNodes) {
321+
for (const { fieldNode } of fieldNodes) {
322322
const key = print(fieldNode);
323323
if (fieldNodeMap[key] == null) {
324324
fieldNodeMap[key] = fieldNode;

packages/utils/src/visitResult.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {
2-
FieldNode,
32
FragmentDefinitionNode,
43
getNullableType,
54
GraphQLError,
@@ -15,7 +14,7 @@ import {
1514
TypeMetaFieldDef,
1615
TypeNameMetaFieldDef,
1716
} from 'graphql';
18-
import { collectFields, collectSubFields } from './collectFields.js';
17+
import { collectFields, collectSubFields, FieldDetails } from './collectFields.js';
1918
import { getOperationASTFromRequest } from './getOperationASTFromRequest.js';
2019
import { ExecutionRequest, ExecutionResult } from './Interfaces.js';
2120
import { Maybe } from './types.js';
@@ -204,7 +203,7 @@ function visitRoot(
204203
function visitObjectValue(
205204
object: Record<string, any>,
206205
type: GraphQLObjectType,
207-
fieldNodeMap: Map<string, FieldNode[]>,
206+
fieldNodeMap: Map<string, FieldDetails[]>,
208207
schema: GraphQLSchema,
209208
fragments: Record<string, FragmentDefinitionNode>,
210209
variableValues: Record<string, any>,
@@ -230,7 +229,7 @@ function visitObjectValue(
230229
}
231230

232231
for (const [responseKey, subFieldNodes] of fieldNodeMap) {
233-
const fieldName = subFieldNodes[0].name.value;
232+
const fieldName = subFieldNodes[0].fieldNode.name.value;
234233
let fieldType = fieldMap[fieldName]?.type;
235234
if (fieldType == null) {
236235
switch (fieldName) {
@@ -257,6 +256,7 @@ function visitObjectValue(
257256
addPathSegmentInfo(type, fieldName, newPathIndex, fieldErrors, errorInfo);
258257
}
259258

259+
// TODO: for fragment arguments we might need to update the variable-values here.
260260
const newValue = visitFieldValue(
261261
object[responseKey],
262262
fieldType,
@@ -322,7 +322,7 @@ function updateObject(
322322
function visitListValue(
323323
list: Array<any>,
324324
returnType: GraphQLOutputType,
325-
fieldNodes: Array<FieldNode>,
325+
fieldNodes: Array<FieldDetails>,
326326
schema: GraphQLSchema,
327327
fragments: Record<string, FragmentDefinitionNode>,
328328
variableValues: Record<string, any>,
@@ -350,7 +350,7 @@ function visitListValue(
350350
function visitFieldValue(
351351
value: any,
352352
returnType: GraphQLOutputType,
353-
fieldNodes: Array<FieldNode>,
353+
fieldGroups: Array<FieldDetails>,
354354
schema: GraphQLSchema,
355355
fragments: Record<string, FragmentDefinitionNode>,
356356
variableValues: Record<string, any>,
@@ -368,7 +368,7 @@ function visitFieldValue(
368368
return visitListValue(
369369
value as Array<any>,
370370
nullableType.ofType,
371-
fieldNodes,
371+
fieldGroups,
372372
schema,
373373
fragments,
374374
variableValues,
@@ -384,7 +384,7 @@ function visitFieldValue(
384384
fragments,
385385
variableValues,
386386
finalType,
387-
fieldNodes,
387+
fieldGroups.map(group => group.fieldNode),
388388
);
389389
return visitObjectValue(
390390
value,
@@ -404,7 +404,7 @@ function visitFieldValue(
404404
fragments,
405405
variableValues,
406406
nullableType,
407-
fieldNodes,
407+
fieldGroups.map(group => group.fieldNode),
408408
);
409409
return visitObjectValue(
410410
value,

0 commit comments

Comments
 (0)