Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier doesn't work when generating .generate.tsx PATH C\\:/folder #9806

Open
belozerov-egor opened this issue Jan 7, 2024 · 0 comments
Open

Comments

@belozerov-egor
Copy link

belozerov-egor commented Jan 7, 2024

Which packages are impacted by your issue?

@graphql-codegen/cli, @graphql-codegen/client-preset

Describe the bug

When generating .generated.tsx files in Prettier, the path is created C \ :/folder. The files are created next to the graphql file, but Prettier itself cannot execute the command due to the path.

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

const config: CodegenConfig = {
  documents: ['src/**/*.graphql'],
  generates: {
    'src/': {
      config: {
        withHooks: true,
      },
      plugins: ['typescript-operations', 'typescript-react-apollo'],
      preset: 'near-operation-file',
      presetConfig: {
        baseTypesPath: '../src/shared/api/generated/types.generated.ts',
        extension: '.generated.tsx',
      },
    },
    'src/shared/api/generated/types.generated.ts': { plugins: ['typescript'] },
  },
  hooks: {
    afterAllFileWrite: ['prettier --write'],
  },
  ignoreNoDocuments: true, // for better experience with the watcher
  schema: 'http://localhost:4000//graphql',
}

export default config

Your Example Website or App

Steps to Reproduce the Bug or Issue

`"C:\Program Files\nodejs\npm.cmd" run codegen:generate

folder@0.1.0 codegen:generate
graphql-codegen

√ Parse Configuration
√ Generate outputs
Error: Command failed: prettier --write src/shared/api/generated/types.generated.ts C:/folder/src/example/example.generated.tsx
[error] No files matching the pattern were found: "C \ :/folder/src/example/example.generated.tsx".

at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:514:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5) {

code: 2,
killed: false,
signal: null,
cmd: 'prettier --write src/shared/api/generated/types.generated.ts C \ :/folder/src/example/example.generated.tsx]'
}

Process finished with exit code 1
`

Expected behavior

a normal path should be created, because the file is created in the same place

Screenshots or Videos

No response

Platform

  • OS: [ Windows]
  • NodeJS: [18.17.0]
  • graphql version: [16.8.1]
    "@graphql-codegen/cli": "^5.0.0",
    "@graphql-codegen/client-preset": "^4.1.0",
    "@graphql-codegen/near-operation-file-preset": "^3.0.0",
    "@graphql-codegen/typescript": "^4.0.1",
    "@graphql-codegen/typescript-operations": "^4.0.1",
    "@graphql-codegen/typescript-react-apollo": "^4.1.0",

Codegen Config File

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant