Skip to content

Release/0.1.0 rc.5 - #21

Merged
monarcode merged 4 commits into
mainfrom
release/0.1.0-rc.5
Nov 21, 2026
Merged

monarcode merged 4 commits into
mainfrom
release/0.1.0-rc.5

Conversation

@monarcode

Copy link
Copy Markdown
Owner

Additive release: opt-in entity sync, two exported errors, named types for
api.query, and namespace docs in editor hovers. It works with
@monarcode/effetch 0.1.0-rc.4 and later in 0.1, as rc.4 does; the peer
ranges are unchanged. One fix can surface in your app: useRefetch with a
key that holds a query now throws instead of doing nothing (see Fixed).

Added

  • Entity sync. Turn it on for the entities to keep in sync:

    QueryClient.make({ layer, entities: { sync: [Todos] } });

    When a query's fetch succeeds, each copy of the entity in its value goes
    over the older copies with the same id in every other query that holds
    it. A details refetch updates the list rows, and a list fetch updates
    the cached details, with no other fetch.

    • The newer copy wins, by when the request that read it started. A slow
      response doesn't overwrite a newer one, a retry counts from when it
      started, and an infinite query's refetch dates each page by its own
      request.
    • Loading the next page sends only that page's copies.
    • A write (Entity.set, Query.set/update, a live push) counts as
      newer than every fetch in flight. It isn't spread to other queries:
      an entity write already reached them, and an optimistic one may roll
      back.
    • A query opts out with entities: { sync: false }
      (Query.EntitiesOptions).
    • An id or a listener that throws is logged with Effect.logError.
      The fetch, and any Query.set or Query.update, keeps its value.

    See "Keep copies in sync" in the README for the full rules and the
    cost. Known limit: when one id appears twice in a response (a row that
    moved between pages during a refetch), the older duplicate isn't
    corrected.

  • Query.KeyHoldsTargetError and, from @monarcode/effetch-query/effetch,
    EndpointQueryError are exported, so you can match them with
    instanceof and name their types. Their tags and messages are unchanged.

  • Named types for api.query: EndpointQueryValue,
    EndpointQueryCallError and EndpointQueryOptionsFor. Go to Definition
    and hovers read more simply; the types each call resolves to are
    unchanged. api.query, api.infiniteQuery and api.mutation have
    examples in their hovers.

  • New README sections:

    • "Responses in other shapes" covers decoding an endpoint's own
      response shape to an entity's schema.
    • "Schemas that transform" covers what server rendering needs: a query
      whose schema can't encode its value is left out of dehydrate with
      no error, and the browser fetches it again.

Fixed

  • useRefetch with a key that holds a query, a family or a group, such as
    useRefetch([todos, profile]), now throws Query.KeyHoldsTargetError
    as it renders, as the README said it does. Before, its refetch did
    nothing and the error was lost. Pass a Query.group instead.

Changed

  • Hovers on the core namespaces (Entity, InfiniteQuery, Mutation,
    Query, QueryClient, Signals) show their docs instead of only the
    module path. A member's hover reads (alias) const Query.make: …. Go to
    Definition on a namespace lands on index.d.ts, and on a member it
    still lands on the member's own declaration.
  • Developed and tested against effect 4.1.5 and @effect/atom-react
    4.1.5.

- `useRefetch` with a key holding a query, family or group now throws
  `Query.KeyHoldsTargetError` as it renders, instead of doing nothing
- Name `api.query`'s types (`EndpointQueryValue`, `EndpointQueryCallError`,
  `EndpointQueryOptionsFor`) in place of inline conditional types
- Develop and test against `effect` 4.1.5 and update dev dependencies
- `QueryClient.make({ entities: { sync: [Todos] } })` writes each fetched copy
  over older copies with the same id in other queries; the newest fetch wins
- A query opts out with `entities: { sync: false }` (`Query.EntitiesOptions`)
- Document entity sync, responses in other shapes and transforming schemas in
  the README
- An infinite query's refetch or retry dates each page by its own attempt
- Loading the next page sends only that page
- A copy no attempt read (a live push during the fetch) counts as a write
- Query.set/update and the sync's writes survive an id or listener that throws
- chore: release 0.1.0-rc.5
@monarcode
monarcode merged commit 6d59b34 into main Nov 21, 2026
3 checks passed
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.

1 participant