dotansimha / dotansimha/graphql-code-generator

Absolute paths are not escaped properly in CLI hooks

Open
#8,654 3 comments 5 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

### Describe the bug

When using the `near-operation-file-preset` with a CLI hook, the absolute path of the generated files are not properly escaped on Windows. For example `C:/myfile.generated.ts` is turned into `C\\:/myfile.generated.ts` which does not work.

Probably related to #8382

### Your Example Website or App

https://github.com/Lehoczky/gql-codegen-near-operation-after-write-bug

### Steps to Reproduce the Bug or Issue

In the example app:

1. install the dependencies
2. run `npm run codegen`
3. see the error

### Expected behavior

Absolute file paths should be escaped in a way that other commands can use them as arguments

### Screenshots or Videos

_No response_

### Platform

- OS: Windows
- NodeJS: v16.17.1
- `graphql` version: ^16.6.0
- "@graphql-codegen/cli": "^2.14.1"
- "@graphql-codegen/near-operation-file-preset": "^2.4.4"
- "@graphql-codegen/typescript": "^2.8.2"
- "@graphql-codegen/typescript-operations": "^2.5.7"

### Codegen Config File

```ts
const config: CodegenConfig = {
schema: "./schema.graphql",
documents: ["./src/**/*.graphql"],
generates: {
"src/types.ts": { plugins: ["typescript"] },
"src/": {
preset: "near-operation-file",
presetConfig: {
baseTypesPath: "types.ts",
},
plugins: ["typescript-operations"],
},
},
hooks: {
afterAllFileWrite: ["prettier --write"],
},
}
```

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