Skip to content

fix: don't stub every field when a mapper type is unresolvable (#446) - #494

Closed
eddeee888 wants to merge 2 commits into
masterfrom
test/reproduce-446-unresolvable-mapper
Closed

fix: don't stub every field when a mapper type is unresolvable (#446)#494
eddeee888 wants to merge 2 commits into
masterfrom
test/reproduce-446-unresolvable-mapper

Conversation

@eddeee888

@eddeee888 eddeee888 commented Sep 7, 2026

Copy link
Copy Markdown
Owner

What this is

Fixes #446: fixObjectTypeResolvers (both 'smart' and 'fast' modes) treated a mapper whose aliased type resolves to the TS error type (e.g. an import to a not-yet-generated module, such as a Prisma client on a fresh install) the same as a mapper that genuinely has zero fields — generating a "resolver is required because ... does not [exist on the mapper]" stub for every field of the schema type and silently overwriting hand-maintained resolvers.

Fixes #446

Fix chosen

Of the options discussed, went with the narrowest, targeted fix: detect the unresolved mapper at the whole-declaration level and skip generation for it entirely (rather than per-property detection, or hard-failing the codegen run).

  • getGraphQLObjectTypeResolversToGenerate.spec.ts — the original checkpoint test proving the bug (now passing), extended to also cover 'fast' mode and the new warning, plus a regression test confirming a genuinely-empty mapper still stubs as before.
  • getNodePropertyMap.ts — adds isNodeTypeUnresolved(), which distinguishes the TS error type (intrinsicName === 'error') from a real any (intrinsicName === 'any') and from a genuinely empty object type (not an intrinsic type at all).
  • getGraphQLObjectTypeResolversToGenerate.ts — in both 'smart' and 'fast' modes, when the mapper's declaration node is unresolved, skip resolver generation for that schema type (leaving existing resolvers untouched) and logger.warn naming the mapper, so the real problem surfaces instead of being masked.
  • Changeset included.

nx build/test/lint typescript-resolver-files all pass.

Note

#455 from the original reporter independently implements essentially the same fix (same intrinsicName === 'error' detection). This PR was written independently against the eddeee888:oss:verify checkpoint rather than building on top of that PR.

@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0a09764

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@eddeee888/gcg-typescript-resolver-files Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

`getGraphQLObjectTypeResolversToGenerate` (both 'smart' and 'fast' modes)
treated a mapper whose type resolves to the TS error type - e.g. one
aliasing an import that doesn't exist yet, such as a Prisma client not
generated on a fresh install - the same as a mapper that genuinely has
zero fields. Every schema field then took the "field is missing from
mapper" branch and got a stub, silently overwriting hand-maintained
resolvers with broken Promise<void> implementations.

Add isNodeTypeUnresolved(), which distinguishes the TS error type
(intrinsicName === 'error') from a real `any` (intrinsicName === 'any')
and from a genuinely empty object type (not an intrinsic type at all).
When a mapper's declaration node is unresolved, skip resolver generation
for that schema type - leaving existing resolvers untouched - and log a
warning naming the mapper so the real problem (the unresolved import)
surfaces instead of being masked.

eddeee888:oss:fix
@eddeee888 eddeee888 changed the title test: reproduce #446 — unresolvable mapper type treated as empty mapper (failing) fix: don't stub every field when a mapper type is unresolvable (#446) Sep 7, 2026
@eddeee888 eddeee888 closed this Sep 7, 2026
@eddeee888
eddeee888 deleted the test/reproduce-446-unresolvable-mapper branch September 7, 2026 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fixObjectTypeResolvers: 'smart' treats an unresolvable mapper type as an empty mapper and injects a stub for every field

1 participant