Skip to main content

useQuery

Callable

  • useQuery<TChainId, TQuery>(builder: TQuery, options?: ChainComposableOptions<TChainId>): (DeepReadonly<MutableAsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, QueryError, undefined>> & { refresh: () => void } & PromiseLike<AsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, QueryError, FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>>>) | (DeepReadonly<MutableAsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, unknown, undefined>> & { refresh: () => void } & PromiseLike<AsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, QueryError, FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>>>)

  • Composable for querying data from chain, and returning the response.


    Type parameters

    • TChainId: any
    • TQuery: (builder: Query<[], ChainDescriptorOf<TChainId>>) => any

    Parameters

    • builder: TQuery

      The function to create the query

    • optionaloptions: ChainComposableOptions<TChainId>

      Additional options

    Returns (DeepReadonly<MutableAsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, QueryError, undefined>> & { refresh: () => void } & PromiseLike<AsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, QueryError, FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>>>) | (DeepReadonly<MutableAsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, unknown, undefined>> & { refresh: () => void } & PromiseLike<AsyncState<FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>, QueryError, FlatHead<InferQueryPayload<Exclude<ReturnType<Exclude<UnwrapRef<TQuery>, Falsy>>, Falsy>>>>>)

    The data response