@gravity-ui/data-source
Version:
A wrapper around data fetching
23 lines (22 loc) • 1.3 kB
TypeScript
import type { Data } from '@normy/core';
import type { QueryClient } from '@tanstack/react-query';
import type { Normalizer, NormalizerConfig } from '../../core/types/Normalizer';
export declare const createQueryNormalizer: (normalizer: Normalizer | undefined, queryClient: QueryClient, config: boolean | NormalizerConfig | undefined, optimisticUpdate: (mutationData: Data) => void, invalidateData: (data: Data) => void) => {
/** Get normalized data */
getNormalizedData: () => import("@normy/core/types/types").NormalizedData;
/** Set normalized data (for manual updates, WebSocket, etc.) */
setNormalizedData: (data: Data) => void;
/** Clear all normalized data */
clear: () => void;
/** Get object by ID */
getObjectById: <T extends Data>(id: string, exampleObject?: T) => T | undefined;
/** Get query fragment */
getQueryFragment: <T extends Data>(fragment: Data, exampleObject?: T) => T | undefined;
/** Get dependent queries by data */
getDependentQueries: (mutationData: Data) => (readonly unknown[])[];
/** Get dependent queries by IDs */
getDependentQueriesByIds: (ids: ReadonlyArray<string>) => (readonly unknown[])[];
/** Subscribe to QueryCache changes */
subscribe: () => void;
unsubscribe: () => void;
} | undefined;