Skip to content

Commit

Permalink
fix(stitch): prevent infinite loop while visiting over the computed f…
Browse files Browse the repository at this point in the history
…ield types
  • Loading branch information
ardatan committed Apr 24, 2024
1 parent b07b76d commit c5df958
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-actors-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@graphql-tools/stitch": patch
---

Prevent infinite loop while visiting over the computed field types
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@ type IsolatedSubschemaInput = Exclude<SubschemaConfig, 'merge'> & {
function filterIsolatedSubschema(subschemaConfig: IsolatedSubschemaInput): SubschemaConfig {
const rootFields: Record<string, boolean> = {};
const computedFieldTypes: Record<string, boolean> = {}; // contains types of computed fields that have no root field

const visitedTypes = new WeakSet<GraphQLNamedOutputType>();
function listReachableTypesToIsolate(
subschemaConfig: SubschemaConfig,
type: GraphQLNamedOutputType,
typeNames?: string[],
typeNames: string[] = [],
) {
typeNames = typeNames || [];

if (visitedTypes.has(type)) {
return typeNames;
}
visitedTypes.add(type);
if (isScalarType(type)) {
return typeNames;
} else if (
Expand Down

0 comments on commit c5df958

Please sign in to comment.