Repository navigation
[graphql-modules-preset] fix: skip sources without a location or document under strict mode (#4683) - #10993
Merged
Conversation
…ment under strict mode (#4683) Fixes the 7 errors `presets/graphql-modules` hits once the root tsconfig enables `strict: true`: - builder.ts: `node.interfaces?.length > 0` compared a possibly-undefined value; default it to 0 (TS18048). - index.ts: `Source.document` is optional, so skip sources without one before `concatAST`, matching core (TS2345). - index.ts: `getConfigValue` infers `T` from the nullable input, so it returned `boolean | undefined`; use `?? true` for `useGraphQLModules` (TS2322). - index.ts: `.filter(Boolean)` does not narrow `rootTypes`; use a `string` type guard (TS2322). - utils.ts: `Source.location` is optional and `path.normalize(undefined)` throws, so skip sources without one in `groupSourcesByModule` (TS2345). Generated output from the CLI is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XSMiQQc6YQZUo1EajQncWL eddeee888:oss:issue-fix
🦋 Changeset detectedLatest commit: 97f8cac The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
24 of 25 tasks
Contributor
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-codegen/core |
6.2.1-alpha-20260926134248-97f8cac45b7bd618516db8d296fb3f4f8ac7f120 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/add |
7.1.1-alpha-20260926134248-97f8cac45b7bd618516db8d296fb3f4f8ac7f120 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/visitor-plugin-common |
7.2.6-alpha-20260926134248-97f8cac45b7bd618516db8d296fb3f4f8ac7f120 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-document-nodes |
6.1.1-alpha-20260926134248-97f8cac45b7bd618516db8d296fb3f4f8ac7f120 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/graphql-modules-preset |
6.1.1-alpha-20260926134248-97f8cac45b7bd618516db8d296fb3f4f8ac7f120 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/testing |
5.0.5-alpha-20260926134248-97f8cac45b7bd618516db8d296fb3f4f8ac7f120 |
npm ↗︎ unpkg ↗︎ |
eddeee888
commented
Sep 26, 2026
eddeee888
commented
Sep 26, 2026
…t when given a default (#4683) `getConfigValue` inferred `T` from both arguments, so a nullable config value made the result nullable even with a non-nullable default. Type `value` as `T | null | undefined` so `T` comes from the default. Under `strict: true` this fixes the two TS2345 errors in base-documents-visitor.ts. With `strictNullChecks` off (current master) the signature is unchanged. graphql-modules goes back to `getConfigValue` for `useGraphQLModules` instead of `?? true`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XSMiQQc6YQZUo1EajQncWL eddeee888:oss:issue-fix
…4683) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XSMiQQc6YQZUo1EajQncWL eddeee888:oss:issue-fix
eddeee888
marked this pull request as ready for review
September 26, 2026 13:44
This was referenced Sep 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of the strict-mode rollout tracked in #10985. This PR fixes the 7 errors
presets/graphql-moduleshits when the root tsconfig turns onstrict: true. It also fixesgetConfigValueinvisitor-plugin-common, which was the root cause of one of those errors.visitor-plugin-commongetConfigValue'svalueparameter is now typedT | null | undefined.Tused to be inferred from the nullable config value, so the result wasX | undefinedeven with a non-nullable default.Tnow comes from the default, so the result is non-nullable. Under strict mode this also fixes the two TS2345 errors inbase-documents-visitor.ts(operationDeclarationKind,avoidOptionals). WithstrictNullChecksoff, as onmastertoday, the signature is unchanged. No caller passes an explicit type argument.presets/graphql-modulesbuilder.ts:node.interfaces?.length > 0compares a value that may beundefined. It now defaults to0(TS18048).index.ts:Source.documentis optional. Sources without one are now skipped beforeconcatAST, the same way core does it (TS2345).index.ts:useGraphQLModulestypechecks through the fixedgetConfigValue(TS2322).index.ts:.filter(Boolean)doesn't narrow the type ofrootTypes. It now uses atypeof name === 'string'type guard (TS2322).utils.ts:Source.locationis optional, andpath.normalize(undefined)throws.groupSourcesByModulenow skips sources without one (TS2345).These are local guards rather than
!assertions, following the review feedback on #10990. CLI output is unchanged. Patch changesets are included for both packages.Related #4683
Type of change
How Has This Been Tested?
strict: truein root tsconfig (#4683) #10985's stricttsconfig.json: 0 errors inpresets/graphql-modules(7 before), and 2 fewer invisitor-plugin-commontsconfig.json: 0 errorspresets/graphql-modules,visitor-plugin-commonand thetypescriptplugins, after a build: all passing🤖 Generated with Claude Code
https://claude.ai/code/session_01XSMiQQc6YQZUo1EajQncWL