Zero 1.5
Schema Change Improvements and Client Group Auth
Installation
npm install @rocicorp/zero@1.5Upgrading
Authenticated Client Groups
The handleQueryRequest and handleMutateRequest helpers now take an options object instead of multiple arguments. They also require a new userID parameter.
Change this:
// query handler
handleQueryRequest(
(name, args) => {
const query = mustGetQuery(queries, name)
return query.fn({args})
},
schema,
request
)
// mutate handler
handleMutateRequest(
dbProvider,
transact =>
transact((tx, name, args) => {
const mutator = mustGetMutator(mutators, name)
return mutator.fn({args, tx})
}),
request
)To this:
// query handler
handleQueryRequest({
handler: (name, args) => {
const query = mustGetQuery(queries, name)
return query.fn({args})
},
schema,
request,
userID
})
// mutate handler
handleMutateRequest({
dbProvider,
handler: transact =>
transact((tx, name, args) => {
const mutator = mustGetMutator(mutators, name)
return mutator.fn({args, tx})
}),
request,
userID
})This is a security enhancement and is recommended for all users. See Why pass userID back to Zero? and PR 5836 for more information. The old signature is still supported but deprecated.
Deploy Order
Make sure to deploy zero-cache before your API server. This is existing standard practice for Zero, but it matters for this release because the 1.5 handleQueryRequest and handleMutateRequest helpers return a new response shape that zero-cache 1.4 cannot parse.
Features
- Schema Change Hooks: Added
zero_<shard>.update_schemas(), so databases that do not support or allow event triggers can manually notify Zero after schema changes. - Authenticated Client Groups:
handleQueryRequestandhandleMutateRequestnow takes auserIDparameter. This enables Zero to enforce that only tabs belonging to the same user can be in the same client group.
Performance
Fixes
CREATE/DROP INDEX CONCURRENTLYcould break replication- Long-lived connections could miss periodic auth revalidation
- Allow omitting
ctxparam when no context type is defined - Make
/keepalivetimeout + graceful-shutdown opt-in except in ECSs Error: pipelines must be initializedduring transform or drain- Shadow sync could miss its first run before
replication-managerrestarted - Row-set drift across view-syncer re-hydration could result in stale rows
- Make WebSocket compression and max-payload settings client-only
Breaking Changes
None. One API was deprecated:
- The positional signatures of
handleQueryRequestandhandleMutateRequest
See Upgrading for more information.