dotansimha / dotansimha/graphql-code-generator

JS heap out of memory when trying to generate schema with nested fields

Open
#9,010 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/cli, @graphql-codegen/add, @graphql-codegen/typescript-operations, @graphql-codegen/typescript

### Describe the bug

The issue is that as soon as I add a WPGraphQL Gutenberg query, which has some nested `blocks`->`innerBlocks`->..., the whole CLI crashes after it hung up for a few minutes, trying to create a gigantic infinite nested schema file.

### Your Example Website or App

https://stackblitz.com/edit/github-gsvfa1

### Steps to Reproduce the Bug or Issue

Open the Stackblitz, try to run `npm run dev`. You will see that it gets stuck while trying to generate the schema and after a few minutes, will throw a JS heap out of memory error.

### Expected behavior

I expect the CLI to have a mechanism built-in that stops the infinite nesting type generation at e.g. 10 nesting levels and just adds "any". This could be configurable.

### Screenshots or Videos

_No response_

### Platform

- OS: macOS
- NodeJS: 16.14.2
- "@graphql-codegen/add": "3.2.1",
- "@graphql-codegen/cli": "2.13.7",
- "@graphql-codegen/typescript": "2.8.0",
- "@graphql-codegen/typescript-operations": "2.5.5",
- "graphql": "^16.2.0"

### Codegen Config File

See Reprod

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.