graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

CLI's `--check` option should not fail due to differences in line endings

Open tiagojufr opened this issue 9 months ago • 2 comments

Which packages are impacted by your issue?

@graphql-codegen/cli

Describe the bug

This is the behavior I see in my Windows 11 machine. Not sure if the same applies to other OS.

graphql-codegen generates files with LF line endings. If something changes that file from LF to CRLF (e.g. git commit and checkout), then graphql-codegen --check will fail, saying the file is stale.

The file content is exactly the same (if we only look at the generated code), so I believe this library should be line ending agnostic and compare the actual code.

I'm not providing a repro as from what I know we can't change line endings in online code editors...

Your Example Website or App

some proprietary app

Steps to Reproduce the Bug or Issue

  1. Run graphql-codegen on any project
  2. Change the line ending on a generated file from LF to CRLF
  3. Run graphql-codegen --check

Expected behavior

I expect that graphql-codegen --check would not fail just because the file has different line endings.

Screenshots or Videos

No response

Platform

  • OS: Windows
  • NodeJS: 22.12.0
  • graphql version: 16.10.0
  • @graphql-codegen/* version(s): 5.0.5

Codegen Config File

codegen.ts

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

const config: CodegenConfig = {
  schema: './src/gql/**/typeDefs.ts',
  generates: {
    './src/types/__generated__/types.ts': {
      plugins: ['typescript', 'typescript-resolvers'],
    },
  },
};

export default config;

Additional context

No response

tiagojufr avatar Mar 05 '25 19:03 tiagojufr

Hi @tiagojufr ,

I've released an alpha version:

@graphql-codegen/cli@5.0.6-alpha-20250414132312-2cacfbb956012f0df94008f4636b6c03ccca15b4

Could you please try and let me know if it fixes your issue?

eddeee888 avatar Apr 22 '25 14:04 eddeee888

Hi @eddeee888,

Tried it out but unfortunately the issue persists.

tiagojufr avatar Apr 23 '25 11:04 tiagojufr