helpersQueryKeys: {
    getDataQuery: (<TPath>(itemResource: Resource<TPath>) => ["query-data", any, {}]);
    getInfiniteList: (<TPath>(itemResource: Resource<TPath>) => ["get-infinite-list", any, {}]);
    getList: (<TPath>(itemResource: Resource<TPath>) => ["get-list", any, {}]);
    getOne: (<TPath>(itemResource: Resource<TPath>, id: string | number) => ["get-one", any, {}, string]);
    getOneArray: (<TPath>(itemResource: Resource<TPath>, ids: (string | number)[]) => ["get-one", any, {}, string][]);
} = ...

A utility object for generating query keys used in React Query.

Type declaration

  • getDataQuery: (<TPath>(itemResource: Resource<TPath>) => ["query-data", any, {}])

    Generates a data query key.

    const key = helpersQueryKeys.getDataQuery(resource);
    // key: ['query-data', 'posts', {}]
      • <TPath>(itemResource): ["query-data", any, {}]
      • Type Parameters

        • TPath extends string

        Parameters

        • itemResource: Resource<TPath>

          The resource object containing the path and parameters for the query.

        Returns ["query-data", any, {}]

        The data query key.

  • getInfiniteList: (<TPath>(itemResource: Resource<TPath>) => ["get-infinite-list", any, {}])

    Generates a query key for fetching an infinite list of items.

    const key = helpersQueryKeys.getInfiniteList(resource);
    // key: ['get-infinite-list', 'posts', {}]
      • <TPath>(itemResource): ["get-infinite-list", any, {}]
      • Type Parameters

        • TPath extends string

        Parameters

        • itemResource: Resource<TPath>

          The resource object containing the path and parameters for the query.

        Returns ["get-infinite-list", any, {}]

        The query key for the infinite list of items.

  • getList: (<TPath>(itemResource: Resource<TPath>) => ["get-list", any, {}])

    Generates a query key for fetching a list of items.

    const key = helpersQueryKeys.getList(resource);
    // key: ['get-list', 'posts', {}]
      • <TPath>(itemResource): ["get-list", any, {}]
      • Type Parameters

        • TPath extends string

        Parameters

        • itemResource: Resource<TPath>

          The resource object containing the path and parameters for the query.

        Returns ["get-list", any, {}]

        The query key for the list of items.

  • getOne: (<TPath>(itemResource: Resource<TPath>, id: string | number) => ["get-one", any, {}, string])

    Generates a query key for fetching a single item by ID.

    const key = helpersQueryKeys.getOne(resource, 1);
    // key: ['get-one', 'posts', {}, '1']
      • <TPath>(itemResource, id): ["get-one", any, {}, string]
      • Type Parameters

        • TPath extends string

        Parameters

        • itemResource: Resource<TPath>

          The resource object containing the path and parameters for the query.

        • id: string | number

          The ID of the item to fetch.

        Returns ["get-one", any, {}, string]

        The query key for the single item.

  • getOneArray: (<TPath>(itemResource: Resource<TPath>, ids: (string | number)[]) => ["get-one", any, {}, string][])

    Generates an array of query keys for fetching multiple items by their IDs.

    const keys = helpersQueryKeys.getOneArray(resource, [1, 2]);
    // keys: [
    // ['get-one', 'posts', {}, '1'],
    // ['get-one', 'posts', {}, '2']
    // ]
      • <TPath>(itemResource, ids): ["get-one", any, {}, string][]
      • Type Parameters

        • TPath extends string

        Parameters

        • itemResource: Resource<TPath>

          The resource object containing the path and parameters for the query.

        • ids: (string | number)[]

          An array of IDs for the items to fetch.

        Returns ["get-one", any, {}, string][]

        An array of query keys for the items.