Queries
Query options
Every option a query takes.
api.query, Query.make and Query.family take the following options:
| Option | Default | What it does |
|---|---|---|
staleTime | 0 | How long a value counts as fresh (a Duration.Input, such as "1 minute"). |
gcTime | 5 minutes | How long a query not in use keeps its value. |
retry | none | A Schedule to retry failed fetches with. |
refetchOnMount | true | Refetch a stale query when a component starts using it. |
retryOnMount | true | Refetch a failed query when a component starts using it. |
refetchOnFocus | true | Refetch stale queries in use when the app comes back into focus. |
refetchOnReconnect | true | Refetch stale queries in use when the device comes back online. |
refetchInterval | none | Refetch on this interval while the query is in use. |
reactivityKeys | none | Also refetch when these Reactivity keys are invalidated (effect/reactivity). |
entities | in sync | { sync: false } leaves the query out of the client's entity sync (Keep copies in sync). |
placeholder | none | A value to show until the query has one (Show a placeholder). |
live | none | Server pushes that keep the value up to date (Push updates into a query). |
schema | none | Query.make and Query.family only: how the value crosses to the browser. |
headers, plugins | none | api.query only: what Effetch's client.bind takes, for every call. |
schema is what Server rendering sends the value
with; an endpoint's output is its schema already
(Queries without Effetch).
Each set of options has a type, for options you define on their own:
Query.Options<E>: the options every query takes, fromstaleTimetoreactivityKeys. It extendsQueryClient.QueryDefaults, the onesqueries.defaultssets.Query.MakeOptions<A, E>:Query.make's, withkey,run,schema,placeholderandlive.placeholderis an Effect andliveaStream.Query.FamilyOptions<Args, A, E>:Query.family's, whererun,placeholderandliveare functions of the member's argument.Query.Schema<A, E>: asuccessschema for the value and, to send failures too, anerrorschema. Each must be a JSON codec that needs no services.EndpointQueryOptions:api.query's, from@monarcode/effetch-query/effetch. Itsplaceholderandliveare functions of the call'sparamsandquery.