graphql-code-generator: typescript-resolvers v4.2.1 causes error when typechecking: `Maximum call stack size exceeded`
Which packages are impacted by your issue?
@graphql-codegen/typescript-resolvers
Describe the bug
With the v4.2.1 release of @graphql-codegen/typescript-resolvers, I started seeing an error Maximum call stack size exceeded when running the typescript compiler. This did not happen on v4.2.0.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- in the linked github repo, check out branch
typescript-resolvers-max-call-stack-exceeded npm installnpm run codegen(optional – the types have already been generated and committed)npm run typecheck- see error
Expected behavior
I expected no error
Screenshots or Videos
No response
Platform
- OS: Windows 11
- NodeJS: 20.13.1
graphqlversion: seepackage.jsonin linked github repo@graphql-codegen/*version(s): seepackage.jsonin linked github repo
Codegen Config File
See linked github repo
Additional context
The full error output I see in the console:
> graphql-codegen-issue-template@1.0.0 typecheck
> tsc
C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:98439
throw e;
^
RangeError: Maximum call stack size exceeded
at Object.createBaseTokenNode (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:22176:39)
at createBaseToken (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:18429:32)
at createBaseLiteral (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:18308:24)
at createBaseStringLiteral (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:18326:24)
at Object.createStringLiteral (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:18331:24)
at typeToTypeNodeWorker (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:43717:88)
at typeToTypeNodeHelper (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:43641:32)
at mapToTypeNodes (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:44401:40)
at typeToTypeNodeWorker (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:43831:37)
at typeToTypeNodeHelper (C:\Users\redacted\projects\graphql-code-generator-issue-sandbox-template\node_modules\typescript\lib\tsc.js:43641:32)
Node.js v20.13.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 17
This is fixed in
@graphql-codegen/typescript-resolvers@4.4.0. Thank you for reporting!Hi all, There will be an option called
avoidCheckingAbstractTypesRecursively. Please use it together with thedefaultMapperoption ifdefaultMapperis recursive:There’s an alpha version here:
4.4.0-alpha-20241014102200-ddc58bcd59abae2c907ea72c013c42ae94232b54Please try it out and let me know if it fixes the issue. Once confirmed, I can try to release it ASAP.@eddeee888 Thank you! That alpha version with the new option fixes the issue for me!
You are right, let me have a chat with the team to understand this a bit more.
This is a bit confusing because both features are documented with the same level of importance and there’s no indication provided other than this comment that users should avoid
defaultMapper. In fact, this exact use ofDeepPartialas thedefaultMapperis an example from the docs.@eddeee888 Yeah, this is for server side code, and my resolvers don’t always return the full type, sometimes there is additional fetching in the “leaves” subtypes so I allow returning partial responses while still ensuring type safety to some degree