dotansimha / dotansimha/graphql-code-generator

`--watch` not working with full paths

Open
#10,388 1 comment 14 reactions 1 assignee Claimed by @eddeee888 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 full paths for codegen in a subfolder, the codegen works, but `--watch` does not.

### Your Example Website or App

https://codesandbox.io/p/sandbox/graphql-code-generator-full-path-watch-pst92d

### Steps to Reproduce the Bug or Issue

1. Run `yarn start`
2. Notice the types file has the correct code
3. Remove `id` from the user query
4. Notice the codegen does not notice the change and types file is still selecting `id`

### Expected behavior

When updating the query, codegen should rerun.

### Screenshots or Videos

_No response_

### Platform

- OS: Linux
- NodeJS: 20.12.1
- `graphql` version: 16.2.0
- `@graphql-codegen/*` version(s):
- add: 5.0.3
- cli: 5.0.7
- typescript: 4.1.6
- typescript-operations: 4.6.1
- `@parcel/watcher`: 2.5.1

### Codegen Config File

```ts
import { CodegenConfig } from "@graphql-codegen/cli";
import { join } from "path";

const config: CodegenConfig = {
schema: join(__dirname, "schema.graphql"),
documents: join(__dirname, "document.graphql"),
generates: {
[join(__dirname, "types.ts")]: {
plugins: ["typescript", "typescript-operations"],
},
},
};

export default config;

```

### Additional context

We needed to use exact full paths because we are in a monorepo and the graphql linter is run from the top level of the repo and the codegen is run from the subfolder.

It looks like the initial codegen does work, it just doesn't watch properly.

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.