# Query options (https://0758e0c7.effetch-query.pages.dev/docs/queries/options)

`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](https://0758e0c7.effetch-query.pages.dev/docs/mutations/entity-sync)). |
| `placeholder`        | none      | A value to show until the query has one ([Show a placeholder](https://0758e0c7.effetch-query.pages.dev/docs/queries/placeholders)).                              |
| `live`               | none      | Server pushes that keep the value up to date ([Push updates into a query](https://0758e0c7.effetch-query.pages.dev/docs/queries/pushes)).                        |
| `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](https://0758e0c7.effetch-query.pages.dev/docs/server-rendering) sends the value
with; an endpoint's `output` is its schema already
([Queries without Effetch](https://0758e0c7.effetch-query.pages.dev/docs/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`.