Skip to content

feat: Add a header to all PostgREST API calls - #14

Merged
ivasilov merged 6 commits into
mainfrom
feat/header-version
Sep 6, 2026
Merged

feat: Add a header to all PostgREST API calls#14
ivasilov merged 6 commits into
mainfrom
feat/header-version

Conversation

@ivasilov

Copy link
Copy Markdown
Member

No description provided.

ivasilov and others added 5 commits September 6, 2026 22:30
The aggregate/groupBy branch of `queryOnce` builds its PostgREST request
via `buildSupabaseQuery`, which is a separate `.setHeader()` call site
from `supabaseQueryFn`. The existing header test used a non-aggregate
query, so it exercised `queryOnceBase` and left that call site
uncovered — removing the header there kept the suite green.

Also pin two behaviours the header docs claim but nothing asserted:
the library value replaces supabase-js's own `X-Client-Info` instead of
appending to it, and user-supplied `global.headers` survive alongside it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ivasilov
ivasilov force-pushed the feat/header-version branch from 448971f to 2ef5ccc Compare September 6, 2026 19:38
The postgres_changes handler called writeInsert for INSERT and
writeUpdate for UPDATE. Both throw when the collection's state does not
match the event: writeInsert raises DuplicateKeySyncError when the key
is already present with different data, and writeUpdate raises
UpdateOperationItemNotFoundError when the key is absent. Because these
run inside a WebSocket callback, neither is catchable by application
code — they surface as unhandled errors that take down the run.

That is not just a test artifact: an INSERT event routinely races the
initial PostgREST fetch, and a channel can replay events after a
reconnect. The e2e suite hit it because a truncate-and-reseed republished
a seeded row into a collection that still held the previous value.

writeUpsert dispatches on key presence and throws in neither direction,
and payload.new is the complete post-change row for INSERT and UPDATE
alike, so it is correct for both. It is available in
@tanstack/query-db-collection 1.0.0, the declared floor, so no
dependency bump is needed. DELETE already guarded with collection.has().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ivasilov
ivasilov force-pushed the feat/header-version branch from 031b3d9 to d79d5c2 Compare September 6, 2026 20:23
@ivasilov
ivasilov merged commit 70241c9 into main Sep 6, 2026
7 checks passed
@ivasilov
ivasilov deleted the feat/header-version branch September 6, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants