Skip to content

Typescript-operations with immutableTypes being true is not using ReadonlyArray for input types #10859

Description

@vinassefranche

Which packages are impacted by your issue?

@graphql-codegen/typescript-operations

Describe the bug

When setting immutableTypes to true in the config of the plugin typescript-operations, the result types for an input having a list is Array instead of ReadonlyArray.
It works well for not input types though.

Your Example Website or App

https://github.com/vinassefranche/codegen-immutable-types-not-set-on-input

Steps to Reproduce the Bug or Issue

  1. run pnpm run generate
  2. look at the generated types.ts file
  3. see the type of SomeInput['books'] using Array<string>

Expected behavior

the type of SomeInput['books'] should use ReadonlyArray<string>

Screenshots or Videos

No response

Platform

  • OS: Linux
  • NodeJS: 24.15.0
  • graphql version: 16.10.0
  • @graphql-codegen/* version(s): 7.0.0

Codegen Config File

import {CodegenConfig} from '@graphql-codegen/cli';

const config: CodegenConfig = {
  schema: 'schema.graphql',
  documents: 'document.graphql',
  generates: {
    'types.ts': {
      plugins: ['typescript-operations'],
      config: {
        immutableTypes: true,
      }
    },
  },
};

export default config;

Additional context

Here's a pull request that attempts to fix the issue: #10806

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions