dotansimha / dotansimha/graphql-code-generator

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

Open
#9,806 2 comments 8 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### 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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.