Repository navigation
[visitor-plugin-common] feat: add documentMode plainString - #11011
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: c6e04d7 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 |
Contributor
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-codegen/fragment-matcher |
7.1.1-alpha-20261012105020-c6e04d7a8566a8caca3735cf74cd45f366ef80a2 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/visitor-plugin-common |
7.3.0-alpha-20261012105020-c6e04d7a8566a8caca3735cf74cd45f366ef80a2 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typed-document-node |
7.2.0-alpha-20261012105020-c6e04d7a8566a8caca3735cf74cd45f366ef80a2 |
npm ↗︎ unpkg ↗︎ |
Generates documents as plain template strings with fragments embedded, without the TypedDocumentString class, its import, or a type cast. Refs #10873 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013F2QpCXY9jqU8vHpGPwbXu
eddeee888
force-pushed
the
claude/quirky-darwin-elesza
branch
from
September 30, 2026 10:39
b690e1a to
0857570
Compare
4 tasks done
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
This PR adds
documentMode: 'plainString', which makes_gql()return a bare template string with fragments embedded, so the generated output has noTypedDocumentStringclass, no import and no type cast.#10873 asks for
documentMode: stringto produce plain strings with no runtime class. Existingstringmode is unchanged, so this is opt-in and non-breaking.With
string:With
plainString:Related #10873
What changed
visitor-plugin-common(client-side-base-visitor.ts):DocumentMode.plainString.stringmode does._gql()returns the bare template string.documentModedocs now describe bothstringandplainString.stringwasn't described there before.typed-document-node: no source change. Itsstringbranches don't matchplainString, so the class template, theDocumentTypeDecorationimport and theas unknown as ...cast are all skipped. Adds an inline-snapshot test.Type of change
How Has This Been Tested?
typed-document-nodeinline-snapshot test:plainStringoutput with an embedded fragment. It checks that no import, class or cast is generated.vitest run: 88 failures incli,graphql-modules-presetandexamples-typescript-graphql-request. The same 88 fail onmasterwithout this change; the only difference is the new passing test.Test Environment:
@graphql-codegen/visitor-plugin-common,@graphql-codegen/typed-document-node: from this branchFurther comments
Known gaps:
plainStringmode, documents are typed asstring, so they don't carry result or variables types. This is intentional: the mode exists to emit plain strings without a type cast.plainStringdocuments carry no__meta__: noonExecutableDocumentNodeoutput, no fragmentfragmentName, and no@deferdeferredFields.plainString; it already passes anydocumentModethrough unvalidated. This is left as-is until it becomes an issue.typescript-react-queryandtypescript-rtk-queryingraphql-code-generator-communityforcedocumentMode: stringand type their fetchers asTypedDocumentString. The reporter's setup needs a matching change there to use this mode.🤖 Generated with Claude Code
https://claude.ai/code/session_013F2QpCXY9jqU8vHpGPwbXu