Skip to content

documentMode: ‘string’ produces types incompatible with strict typescript #10021

Closed
@vruffer

Description

@vruffer

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

I want to prefice this by saying it might be a feature request, depending on how you look at it.

When using @graphql-codegen/cli with preset: ‘client’ and documentMode: ‘string’, the generated class TypedDocumentString is incompatible with the typescript options noImplicitOverride and exactOptionalPropertyChecks.

There is a workaround which is to disable those two rules, but since you cannot (as far as I can tell) create typescript rules specific to certain files, you have to disable the rules for the entire project.

Your Example Website or App

https://github.com/vruffer/graphql-strict-ts-error

Steps to Reproduce the Bug or Issue

  1. Clone repo
  2. Run yarn install
  3. Run yarn codegen
  4. Run yarn check

Expected behavior

I expected the generated typescript to be valid with the strictest settings possible

Screenshots or Videos

No response

Platform

  • OS: MacOS
  • NodeJS: 20.14.0
  • graphql version: 16.9.0
  • @graphql-codegen/cli version: 5.0.2

Codegen Config File

{
  overwrite: true,
  generates: {
    './src/gql/': {
      schema: ['./src/schema.graphql'],
      preset: 'client',
      config: {
        documentMode: 'string',
      },
      documents: ['./src/operations.ts'],
    },
  },
}

Additional context

No response

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