graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

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

Open madebyfabian opened this issue 2 years ago • 2 comments

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

madebyfabian avatar Feb 19 '23 08:02 madebyfabian

Related https://github.com/dotansimha/graphql-code-generator/issues/7720

dimaMachina avatar Feb 20 '23 01:02 dimaMachina

the related issue is closed in 2022, stumbled on this issue because we're constantly facing out of memory crashes

egucciar avatar Mar 06 '24 21:03 egucciar