Skip to content

API Documentation / @pinia/colada / UseQueryEntry

Interface: UseQueryEntry<TData, TError, TDataInitial> ​

A query entry in the cache.

Type Parameters ​

TData ​

TData = unknown

TError ​

TError = unknown

TDataInitial ​

TDataInitial extends TData | undefined = unknown extends TData ? unknown : undefined

Properties ​

active ​

ts
readonly active: boolean;

Whether the query is currently being used by a Component or EffectScope (e.g. a store).


asyncStatus ​

ts
asyncStatus: ShallowRef<AsyncStatus>;

The status of the query.


deps ​

ts
deps: Set<EffectScope | ComponentInternalInstance>;

Components and effects scopes that use this query entry.


ext ​

ts
readonly ext: UseQueryEntryExtensions<TData, TError, TDataInitial>;

Extensions to the query entry added by plugins. You should only add properties to the object, not replace it.


gcTimeout ​

ts
gcTimeout: Timeout | undefined;

Timeout id that scheduled a garbage collection. It is set here to clear it when the entry is used by a different component


key ​

ts
key: EntryKey;

The serialized key associated with this query entry.


keyHash ​

ts
keyHash: string;

Seriaized version of the key. Used to retrieve the entry from the cache.


meta ​

ts
meta: QueryMeta;

Resolved meta information for this query. This is the computed value from options.meta (function/ref resolved to raw object).


options ​

ts
options: 
  | UseQueryOptionsWithDefaults<TData, TError, TDataInitial>
  | null;

Options used to create the query. They can be null during hydration but are needed for fetching. This is why store.ensure() sets this property. Note these options might be shared by multiple query entries when the key is dynamic and that's why some methods like fetch receive the options as an argument.


pending ​

ts
pending: 
  | {
  abortController: AbortController;
  refreshCall: Promise<DataState<TData, TError, TDataInitial>>;
  when: number;
}
  | null;

The current pending request.

Union Members ​

Type Literal ​
ts
{
  abortController: AbortController;
  refreshCall: Promise<DataState<TData, TError, TDataInitial>>;
  when: number;
}
abortController ​
ts
abortController: AbortController;

The abort controller used to cancel the request and which signal is passed to the query function.

refreshCall ​
ts
refreshCall: Promise<DataState<TData, TError, TDataInitial>>;

The promise created by queryCache.fetch that is currently pending.

when ​
ts
when: number;

When was this pending object created.


null


placeholderData ​

ts
placeholderData: TData | TDataInitial | null | undefined;

A placeholder data that is initially shown while the query is loading for the first time. This will also show the status as success until the query finishes loading (no matter the outcome).


stale ​

ts
readonly stale: boolean;

Whether the data is stale or not, requires options.staleTime to be set.


state ​

ts
state: ShallowRef<DataState<TData, TError, TDataInitial>>;

The state of the query. Contains the data, error and status.


when ​

ts
when: number;

When was this data set in the entry for the last time in ms. It can also be 0 if the entry has been invalidated.

Released under the MIT License.