Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(federation): prevent infinite loop while visiting over the comput…
Browse files Browse the repository at this point in the history
…ed field types
ardatan committed Apr 24, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
tvdeyen Thomas von Deyen
1 parent b07b76d commit 8beb141
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
@@ -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 (

0 comments on commit 8beb141

Please sign in to comment.