fix(FR-2829): move relay:watch to root and fix schema watch paths#7278
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has required the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage Report for root-coverage
File CoverageNo changed files found. |
Coverage Report for react-coverage (./react)
File CoverageNo changed files found. |
There was a problem hiding this comment.
Pull request overview
Moves Relay watch mode orchestration to the monorepo root so the dev script no longer needs to cd react, and updates watch paths to track the schema files under /data.
Changes:
- Updated
scripts/dev.mjsto runpnpm run relay:watchfrom the repo root. - Removed
relay:watch(andnodemon) fromreact/package.json. - Added a new root-level
relay:watchscript usingnodemonto restart Relay when schema/directives change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
scripts/dev.mjs |
Switches dev concurrently command from cd react && ... to root-level pnpm run relay:watch. |
react/package.json |
Removes the React-package-local relay:watch script and nodemon devDependency. |
package.json |
Adds root relay:watch script with corrected watch paths and adds nodemon to devDependencies. |
6584fb5 to
0d99eea
Compare
0d99eea to
1624c5d
Compare
|
Follow-up simplification (commit 1624c5d): dropped the |
Merge activity
|
) Resolves #7277(FR-2829) ## Why `react/package.json`'s `relay:watch` script tells nodemon to watch `schema.graphql` and `client-directives.graphql` *relative to the script's cwd* (`react/`). The actual schema files live at `data/schema.graphql` and `data/client-directives.graphql` (project root). `react/schema.graphql` does not exist, so nodemon silently watched nothing — `relay-compiler` was never restarted on schema changes, and the merge side-effect in `relay-base.config.js` (which writes `data/merged_schema.graphql`) never re-ran. The compiler kept validating against a stale merged schema. ## What - Add a working `relay:watch` script at the root `package.json` that watches the real `data/*.graphql` paths and dispatches into the react workspace via `pnpm run --prefix ./react relay --watch`. - Add `nodemon` as a root `devDependency` (it was previously only in `react/`). The script needs `nodemon` to resolve from the root cwd; using `pnpm --filter ./react exec nodemon` was rejected because it would shift cwd back into `react/` and reintroduce the same path bug. - Update `scripts/dev.mjs:60` to call the new root script instead of `cd react && pnpm run relay:watch`. - Delete the now-redundant `relay:watch` script and the `nodemon` devDep from `react/package.json` so there is exactly one place that owns the watch behavior. The script and the dep were the only two `nodemon` references in the workspace. - `relay-base.config.js` is intentionally untouched — the merge side-effect there is correct; only the watch wiring was broken. ## Review feedback applied - **Lockfile sync (must-fix from @nowgnuesLee)**: regenerated `pnpm-lock.05-07-fix_fr-2829_*.yaml` (per-branch lockfile, project convention via `gitBranchLockfile: true` + weekly merge workflow). nodemon now resolves from the root `.:` importer, removed from the `react:` importer. Diff is the nodemon move only — no unrelated dependency hash drift. - **README update (should-fix from Copilot/@nowgnuesLee)**: updated `README.md:234` Commands Reference from `cd react && pnpm run relay:watch` to `pnpm run relay:watch`. `AGENTS.md:147` was already correct. - **`--prefix` consistency (nit from Copilot/@nowgnuesLee)**: switched the inner dispatch from `pnpm --filter ./react run relay --watch` to `pnpm run --prefix ./react relay --watch` to match the rest of the repo (`package.json:23`, `package.json:120`, `scripts/dev.mjs:61`). cwd stays at root for nodemon's watch resolution; only the inner `pnpm run` is dispatched into `react/`. Re-ran the smoke test below — still works. ## Follow-up simplification - Removed the vestigial `pnpm --prefix ./react` dispatch in `relay:watch`. Root `relay.config.js` already defines both `react` and `backend.ai-ui` as projects (`sources` maps both `react/src` and `packages/backend.ai-ui/src`), so `pnpm run relay --watch` from root compiles **both** projects in a single relay-compiler invocation. The `--prefix ./react` hop added a cwd change with no functional effect — relay-compiler is config-driven, not cwd-driven, and walks up to the same root `relay.config.js` either way. Verified via smoke test that both `react/src/__generated__/` and `packages/backend.ai-ui/src/__generated__/` remain in sync after schema changes. ## Test plan Verification harness: - [x] `bash scripts/verify.sh` — Relay/Lint/Format **PASS**. TypeScript fails with the same set of pre-existing errors that fail on `main` (`packages/backend.ai-client/src/client.ts` implicit-any errors, `DeleteForeverVFolderModalV2.tsx` `BulkPurgeVFoldersV2Input` mismatch); confirmed by stashing this PR's changes and re-running on clean main. Unrelated to this change. Smoke test (the load-bearing one): - [x] `pnpm run relay:watch` starts successfully and logs `watching path(s): data/schema.graphql data/client-directives.graphql` (correct paths now, not `schema.graphql` resolving to nowhere). - [x] Initial relay-compiler output mentions **both** projects: `[backend.ai-ui] compiling...` and `[react] compiling...`, followed by per-project `compiled documents` lines (100/66/92 for backend.ai-ui, 414/262/448 for react). - [x] `touch data/schema.graphql` triggers `[nodemon] restarting due to changes...` and a fresh `relay-compiler` cycle that again mentions both projects. - [x] `data/merged_schema.graphql`'s mtime updates after the touch — proving `relay-base.config.js`'s schema-merge side-effect actually re-runs on schema changes (the original bug). - [ ] (Recommend reviewer) `pnpm run dev` end-to-end: confirm the `react-relay` concurrently pane starts via the root script and behaves the same as before, just with working schema watching.
1624c5d to
fc0b319
Compare

Resolves #7277(FR-2829)
Why
react/package.json'srelay:watchscript tells nodemon to watchschema.graphqlandclient-directives.graphqlrelative to the script's cwd (react/). The actual schema files live atdata/schema.graphqlanddata/client-directives.graphql(project root).react/schema.graphqldoes not exist, so nodemon silently watched nothing —relay-compilerwas never restarted on schema changes, and the merge side-effect inrelay-base.config.js(which writesdata/merged_schema.graphql) never re-ran. The compiler kept validating against a stale merged schema.What
relay:watchscript at the rootpackage.jsonthat watches the realdata/*.graphqlpaths and dispatches into the react workspace viapnpm run --prefix ./react relay --watch.nodemonas a rootdevDependency(it was previously only inreact/). The script needsnodemonto resolve from the root cwd; usingpnpm --filter ./react exec nodemonwas rejected because it would shift cwd back intoreact/and reintroduce the same path bug.scripts/dev.mjs:60to call the new root script instead ofcd react && pnpm run relay:watch.relay:watchscript and thenodemondevDep fromreact/package.jsonso there is exactly one place that owns the watch behavior. The script and the dep were the only twonodemonreferences in the workspace.relay-base.config.jsis intentionally untouched — the merge side-effect there is correct; only the watch wiring was broken.Review feedback applied
pnpm-lock.05-07-fix_fr-2829_*.yaml(per-branch lockfile, project convention viagitBranchLockfile: true+ weekly merge workflow). nodemon now resolves from the root.:importer, removed from thereact:importer. Diff is the nodemon move only — no unrelated dependency hash drift.README.md:234Commands Reference fromcd react && pnpm run relay:watchtopnpm run relay:watch.AGENTS.md:147was already correct.--prefixconsistency (nit from Copilot/@nowgnuesLee): switched the inner dispatch frompnpm --filter ./react run relay --watchtopnpm run --prefix ./react relay --watchto match the rest of the repo (package.json:23,package.json:120,scripts/dev.mjs:61). cwd stays at root for nodemon's watch resolution; only the innerpnpm runis dispatched intoreact/. Re-ran the smoke test below — still works.Follow-up simplification
pnpm --prefix ./reactdispatch inrelay:watch. Rootrelay.config.jsalready defines bothreactandbackend.ai-uias projects (sourcesmaps bothreact/srcandpackages/backend.ai-ui/src), sopnpm run relay --watchfrom root compiles both projects in a single relay-compiler invocation. The--prefix ./reacthop added a cwd change with no functional effect — relay-compiler is config-driven, not cwd-driven, and walks up to the same rootrelay.config.jseither way. Verified via smoke test that bothreact/src/__generated__/andpackages/backend.ai-ui/src/__generated__/remain in sync after schema changes.Test plan
Verification harness:
bash scripts/verify.sh— Relay/Lint/Format PASS. TypeScript fails with the same set of pre-existing errors that fail onmain(packages/backend.ai-client/src/client.tsimplicit-any errors,DeleteForeverVFolderModalV2.tsxBulkPurgeVFoldersV2Inputmismatch); confirmed by stashing this PR's changes and re-running on clean main. Unrelated to this change.Smoke test (the load-bearing one):
pnpm run relay:watchstarts successfully and logswatching path(s): data/schema.graphql data/client-directives.graphql(correct paths now, notschema.graphqlresolving to nowhere).[backend.ai-ui] compiling...and[react] compiling..., followed by per-projectcompiled documentslines (100/66/92 for backend.ai-ui, 414/262/448 for react).touch data/schema.graphqltriggers[nodemon] restarting due to changes...and a freshrelay-compilercycle that again mentions both projects.data/merged_schema.graphql's mtime updates after the touch — provingrelay-base.config.js's schema-merge side-effect actually re-runs on schema changes (the original bug).pnpm run devend-to-end: confirm thereact-relayconcurrently pane starts via the root script and behaves the same as before, just with working schema watching.