[PR #233] [CLOSED] Fix infinite recursion in GraphQL docs explorer when handling circular type references #158

Closed
opened 2025-12-29 07:19:35 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mountain-loop/yaak/pull/233
Author: @jonasnobile
Created: 7/7/2025
Status: Closed

Base: masterHead: fix/infinite-recursion-in-docs-explorer


📝 Commits (1)

  • 8b7d74c fix: infinite recursion in type graph traversal

📊 Changes

1 file changed (+11 additions, -1 deletions)

View changed files

📝 src-web/components/GraphQLDocsExplorer.tsx (+11 -1)

📄 Description

Problem

The GraphQL docs explorer was throwing "Maximum call stack size exceeded" errors due to infinite recursion when processing GraphQL schemas with circular type references.

Root Cause

The getFieldsIndices and getTypeIndices functions were calling each other recursively without checking for already-processed types:

  • getFieldsIndices processes fields and calls getTypeIndices for each field's type
  • getTypeIndices processes types and calls getFieldsIndices for the type's fields
  • When schemas contain circular references (Type A → Type B → Type A), this creates infinite recursion

Solution

Added a visited set to track which types have been processed:

  • Added visitedTypes: Set<string> to IndexGenerationContext
  • Check if a type has already been visited before processing it
  • Mark types as visited when starting to process them
  • Initialize a new visited set for each root type processing

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mountain-loop/yaak/pull/233 **Author:** [@jonasnobile](https://github.com/jonasnobile) **Created:** 7/7/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/infinite-recursion-in-docs-explorer` --- ### 📝 Commits (1) - [`8b7d74c`](https://github.com/mountain-loop/yaak/commit/8b7d74c8037ff827f550c336b29f711ae359f2c3) fix: infinite recursion in type graph traversal ### 📊 Changes **1 file changed** (+11 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src-web/components/GraphQLDocsExplorer.tsx` (+11 -1) </details> ### 📄 Description ## Problem The GraphQL docs explorer was throwing "Maximum call stack size exceeded" errors due to infinite recursion when processing GraphQL schemas with circular type references. ## Root Cause The `getFieldsIndices` and `getTypeIndices` functions were calling each other recursively without checking for already-processed types: - `getFieldsIndices` processes fields and calls `getTypeIndices` for each field's type - `getTypeIndices` processes types and calls `getFieldsIndices` for the type's fields - When schemas contain circular references (Type A → Type B → Type A), this creates infinite recursion ## Solution Added a visited set to track which types have been processed: - Added `visitedTypes: Set<string>` to `IndexGenerationContext` - Check if a type has already been visited before processing it - Mark types as visited when starting to process them - Initialize a new visited set for each root type processing --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 07:19:35 +01:00
adam closed this issue 2025-12-29 07:19:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/yaak#158