dotansimha/graphql-code-generator

git generates: warning: LF will be replaced by CRLF in src/graphql/generated/fragment-matcher.ts

Open

#5154 opened on Dec 1, 2020

View on GitHub
 (3 comments) (3 reactions) (0 assignees)TypeScript (10,341 stars) (1,295 forks)batch import
help wantedpluginsstage/1-reproduction

Description

Describe the bug

Whenever we create a new file with extension .graphql and run graphql-codegen to generate the required files for typescript we get the following error from git:

image

To Reproduce

  • Create a file test.graphql on a Windows machine
  • Run graphql-codegen
  • Add the newly generated files to git git add .

    Notice line ending warnings

The GraphQL generated code can be found here.

  1. My codegen.js config file:
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-var-requires */

const fs = require('fs')

const token = fs.readFileSync('./token.txt')

module.exports = {
  overwrite: true,
  schema: {
    [process.env.BACKEND_API_URI]: {
      headers: {
        Authorization: `Bearer ${token}`,
      },
    },
  },
  documents: 'src/**/*.graphql',
  hooks: {
    afterAllFileWrite: ['prettier --write'],
  },
  generates: {
    'src/graphql/generated/schema.json': {
      plugins: ['introspection'],
    },
    'src/graphql/generated/operations.ts': {
      plugins: [
        {
          add: {
            content: '/* eslint-disable */',
          },
        },
        'typescript',
        'typescript-operations',
        'typescript-vue-apollo',
      ],
      config: { withCompositionFunctions: true },
    },
    'src/graphql/generated/fragment-matcher.ts': ['fragment-matcher'],
  },
}

Expected behavior No line ending warnings as this isn't happening for manually created files.

Environment:

  • OS: Windows Server 2016
  • @graphql-codegen/...:
    "@graphql-codegen/add": "^2.0.2",
    "@graphql-codegen/cli": "^1.19.4",
    "@graphql-codegen/fragment-matcher": "2.0.1",
    "@graphql-codegen/introspection": "1.18.1",
    "@graphql-codegen/typescript": "^1.19.0",
    "@graphql-codegen/typescript-operations": "^1.17.12",
    "@graphql-codegen/typescript-vue-apollo": "^2.3.1",
  • NodeJS: v12.18.1

Contributor guide