← Dev log
EduQate·frontend·2026-07-18

A save that worked and still looked broken

The save persisted correctly but never invalidated the React Query cache, so reopening the form showed stale data and looked like the write had been lost.

It said it worked

Green, 200, saved, “already handled” — and wrong. No error anywhere to go on.

Added a field in the form builder, hit Save Draft, reopened, and the field was gone. Reproduced it once more before trusting it.

Checked the obvious suspects first — maybe Add Field only touches local state, maybe the save is silently failing. Neither. The save genuinely creates a new version and persists every section and field, confirmed server-side. The bug is one step later: the save handler never invalidates the cached template list that Edit Form reads to decide which version to reopen, unlike its two sibling mutations which both do. So the save succeeds completely and the next read serves a stale answer, showing an older version that really doesn't have the field.

One qc.invalidateQueries() call. "The data didn't save" and "the data saved and the UI is reading stale cache" look identical from the user's side, and only one is a persistence bug. Worth checking against the database or a hard reload before assuming the mutation is broken, especially when sibling mutations in the same file already invalidate correctly — that's a strong hint the bug is inconsistency between siblings.