Skip to content

Commit 6c8ad45

Browse files
IvanGoncharovyaacovCR
authored andcommitted
remove unneeded check for cycles
1 parent 81c5ed9 commit 6c8ad45

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

src/execution/__tests__/abstract-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ describe('Execute: Handles execution of abstract types', () => {
752752
// FIXME: workaround since we can't inject resolveType into SDL
753753
petType.resolveType = () => 'Pet';
754754
expectError().toEqual(
755-
'Abstract type resolution for "Named" for field "Query.named" failed. Encountered abstract type "Pet" resolved to "Pet", causing a cycle.',
755+
'Abstract type resolution for "Named" for field "Query.named" failed. Interface type "Pet" is not a subtype of encountered interface type "Named".',
756756
);
757757
});
758758
});

src/execution/execute.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,6 @@ function resolveType(
836836
fieldNodes: ReadonlyArray<FieldNode>,
837837
info: GraphQLResolveInfo,
838838
result: unknown,
839-
encounteredTypeNames: Set<string> = new Set(),
840839
): GraphQLObjectType | Promise<GraphQLObjectType> {
841840
const resolveTypeFn = abstractType.resolveType ?? exeContext.typeResolver;
842841
const contextValue = exeContext.contextValue;
@@ -857,7 +856,6 @@ function resolveType(
857856
fieldNodes,
858857
info,
859858
result,
860-
encounteredTypeNames,
861859
),
862860
);
863861
}
@@ -869,7 +867,6 @@ function resolveType(
869867
fieldNodes,
870868
info,
871869
result,
872-
encounteredTypeNames,
873870
);
874871
}
875872

@@ -881,7 +878,6 @@ function deriveRuntimeType(
881878
fieldNodes: ReadonlyArray<FieldNode>,
882879
info: GraphQLResolveInfo,
883880
result: unknown,
884-
encounteredTypeNames: Set<string>,
885881
): GraphQLObjectType | Promise<GraphQLObjectType> {
886882
if (runtimeTypeName == null) {
887883
throw new GraphQLError(
@@ -909,14 +905,6 @@ function deriveRuntimeType(
909905
);
910906
}
911907

912-
if (encounteredTypeNames.has(runtimeTypeName)) {
913-
throw new GraphQLError(
914-
`Abstract type resolution for "${returnType.name}" for field "${info.parentType.name}.${info.fieldName}" failed. ` +
915-
`Encountered abstract type "${currentAbstractType.name}" resolved to "${runtimeTypeName}", causing a cycle.`,
916-
);
917-
}
918-
encounteredTypeNames.add(runtimeTypeName);
919-
920908
const runtimeType = exeContext.schema.getType(runtimeTypeName);
921909
if (runtimeType == null) {
922910
throw new GraphQLError(
@@ -942,7 +930,6 @@ function deriveRuntimeType(
942930
fieldNodes,
943931
info,
944932
result,
945-
encounteredTypeNames,
946933
);
947934
}
948935

0 commit comments

Comments
 (0)