UNPKG

@n1ru4l/graphql-live-query-patch

Version:

Shared logic for building live query patch implementations.

17 lines (16 loc) 1.19 kB
import { LiveExecutionResult } from "@n1ru4l/graphql-live-query"; import { Repeater } from "@repeaterjs/repeater"; import type { ExecutionResult } from "graphql"; import type { ExecutionPatchResult } from "./ExecutionPatchResult.js"; import type { ExecutionLivePatchResult } from "./ExecutionLivePatchResult.js"; /** * Symbol that indicates that there is no diff between the previous and current state and thus no patch must be sent to the client. * This value should be returned from GeneratePatchFunction. */ export declare const noDiffSymbol: unique symbol; export declare type GeneratePatchFunction<PatchPayload = unknown> = (previous: Record<string, unknown>, current: Record<string, unknown>) => PatchPayload | typeof noDiffSymbol; export declare const createLiveQueryPatchGenerator: <PatchPayload = unknown>(generatePatch: GeneratePatchFunction<PatchPayload>) => (source: AsyncIterableIterator<LiveExecutionResult>) => Repeater<ExecutionResult<import("graphql/jsutils/ObjMap").ObjMap<unknown>, import("graphql/jsutils/ObjMap").ObjMap<unknown>> | ExecutionLivePatchResult<unknown> | ExecutionPatchResult<{ [key: string]: any; }, { [key: string]: any; }>, any, unknown>;