Skip to Content
Effetch Query
Queries

Query options

Every option a query takes.

api.query, Query.make and Query.family take the following options:

OptionDefaultWhat it does
staleTime0How long a value counts as fresh (a Duration.Input, such as "1 minute").
gcTime5 minutesHow long a query not in use keeps its value.
retrynoneA Schedule to retry failed fetches with.
refetchOnMounttrueRefetch a stale query when a component starts using it.
retryOnMounttrueRefetch a failed query when a component starts using it.
refetchOnFocustrueRefetch stale queries in use when the app comes back into focus.
refetchOnReconnecttrueRefetch stale queries in use when the device comes back online.
refetchIntervalnoneRefetch on this interval while the query is in use.
reactivityKeysnoneAlso refetch when these Reactivity keys are invalidated (effect/reactivity).
entitiesin sync{ sync: false } leaves the query out of the client's entity sync (Keep copies in sync).
placeholdernoneA value to show until the query has one (Show a placeholder).
livenoneServer pushes that keep the value up to date (Push updates into a query).
schemanoneQuery.make and Query.family only: how the value crosses to the browser.
headers, pluginsnoneapi.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, from staleTime to reactivityKeys. It extends QueryClient.QueryDefaults, the ones queries.defaults sets.
  • Query.MakeOptions<A, E>: Query.make's, with key, run, schema, placeholder and live. placeholder is an Effect and live a Stream.
  • Query.FamilyOptions<Args, A, E>: Query.family's, where run, placeholder and live are functions of the member's argument.
  • Query.Schema<A, E>: a success schema for the value and, to send failures too, an error schema. Each must be a JSON codec that needs no services.
  • EndpointQueryOptions: api.query's, from @monarcode/effetch-query/effetch. Its placeholder and live are functions of the call's params and query.