From 16b95293c36046ed9328bab629c9a2baf4430f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Fran=C3=A7ois?= Date: Mon, 15 Jun 2026 16:17:13 +0200 Subject: [PATCH 1/2] Fix Array used instead of ReadonlyArray for input type when immutableTypes config is on (#10806) * Fix Array used instead of ReadonlyArray for input type when immutableTypes config is on * Add changeset --------- Co-authored-by: Eddy Nguyen --- .changeset/four-cameras-enter.md | 5 +++++ packages/plugins/typescript/operations/src/visitor.ts | 3 ++- .../tests/ts-documents.standalone.input.spec.ts | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changeset/four-cameras-enter.md diff --git a/.changeset/four-cameras-enter.md b/.changeset/four-cameras-enter.md new file mode 100644 index 00000000000..339b5b65bb4 --- /dev/null +++ b/.changeset/four-cameras-enter.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/typescript-operations': patch +--- + +Fix Array used instead of ReadonlyArray while immutableTypes config is true diff --git a/packages/plugins/typescript/operations/src/visitor.ts b/packages/plugins/typescript/operations/src/visitor.ts index 6b9e7d3eb95..8f8461b0210 100644 --- a/packages/plugins/typescript/operations/src/visitor.ts +++ b/packages/plugins/typescript/operations/src/visitor.ts @@ -327,7 +327,8 @@ export class TypeScriptDocumentsVisitor extends BaseDocumentsVisitor< } if (typeNode.type === 'ListType') { - typePart = `Array<${typePart}>`; + const listModifier = this.config.immutableTypes ? 'ReadonlyArray' : 'Array'; + typePart = `${listModifier}<${typePart}>`; if (!typeNode.isNonNullable) { typePart = printTypeScriptMaybeType({ type: typePart, diff --git a/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts b/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts index 9654ad5955f..b4ef422bd22 100644 --- a/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts +++ b/packages/plugins/typescript/operations/tests/ts-documents.standalone.input.spec.ts @@ -241,10 +241,10 @@ describe('TypeScript Operations Plugin - Input', () => { readonly to?: Date | null | undefined; readonly timezone?: unknown; readonly role?: UserRole | null | undefined; - readonly ageRange1?: Array | null | undefined; - readonly ageRange2: Array; - readonly ageRange3?: Array | null | undefined; - readonly ageRange4: Array; + readonly ageRange1?: ReadonlyArray | null | undefined; + readonly ageRange2: ReadonlyArray; + readonly ageRange3?: ReadonlyArray | null | undefined; + readonly ageRange4: ReadonlyArray; readonly bestFriend?: UsersBestFriendInput | null | undefined; readonly nestedInput?: UsersInput | null | undefined; }; From c12464589231d783bb1efd48742e17c9ef3a0884 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 16 Jun 2026 00:28:49 +1000 Subject: [PATCH 2/2] chore(release): update monorepo packages versions (#10868) Co-authored-by: github-actions[bot] --- .changeset/four-cameras-enter.md | 5 ----- packages/plugins/typescript/operations/CHANGELOG.md | 9 +++++++++ packages/plugins/typescript/operations/package.json | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) delete mode 100644 .changeset/four-cameras-enter.md diff --git a/.changeset/four-cameras-enter.md b/.changeset/four-cameras-enter.md deleted file mode 100644 index 339b5b65bb4..00000000000 --- a/.changeset/four-cameras-enter.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@graphql-codegen/typescript-operations': patch ---- - -Fix Array used instead of ReadonlyArray while immutableTypes config is true diff --git a/packages/plugins/typescript/operations/CHANGELOG.md b/packages/plugins/typescript/operations/CHANGELOG.md index 9c87944a3fd..10161e07836 100644 --- a/packages/plugins/typescript/operations/CHANGELOG.md +++ b/packages/plugins/typescript/operations/CHANGELOG.md @@ -1,5 +1,14 @@ # @graphql-codegen/typescript-operations +## 6.0.4 + +### Patch Changes + +- [#10806](https://github.com/dotansimha/graphql-code-generator/pull/10806) + [`16b9529`](https://github.com/dotansimha/graphql-code-generator/commit/16b95293c36046ed9328bab629c9a2baf4430f5f) + Thanks [@vinassefranche](https://github.com/vinassefranche)! - Fix Array used instead of + ReadonlyArray while immutableTypes config is true + ## 6.0.3 ### Patch Changes diff --git a/packages/plugins/typescript/operations/package.json b/packages/plugins/typescript/operations/package.json index 8007b703cf3..d2b1941596c 100644 --- a/packages/plugins/typescript/operations/package.json +++ b/packages/plugins/typescript/operations/package.json @@ -1,6 +1,6 @@ { "name": "@graphql-codegen/typescript-operations", - "version": "6.0.3", + "version": "6.0.4", "type": "module", "description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments", "repository": {