import type { ApolloError, DocumentNode, QueryHookOptions, SubscribeToMoreOptions } from "@apollo/client"; import { Node } from "./uniqueNodes"; import { Edge } from "./uniqueEdges"; interface UseCollectionQueryArguments { /** * The graphQL query that fetches the collection */ query: DocumentNode; /** * A list of options for us to pass into the apollo `useQuery` hook */ queryOptions?: QueryHookOptions; /** * A function that returns the location where the {@link Collection} is located. * * The collection is the part of the result that needs to be paginated. */ getCollectionByPath: GetCollectionByPathFunction; /** * A list of subscription options if you want to create a GraphQL * subscription to listen for more content. */ subscription?: ListSubscription; } interface ListSubscription { /** * The graphQL subscription that listens for more data. This query should * return a single Node that matches the data structure in * `getCollectionByPath(...).edges.node` and * `getCollectionByPath(...).nodes */ document: DocumentNode; /** * A list of variables to pass into the apollo `subscribeToMore` function. */ options?: Pick, "variables">; /** * A function that returns the location where the `Node` is located on the * `TSubscription` object. * * It should return a single Node that matches the data structure in * `getCollectionByPath(...).edges.node` and * `getCollectionByPath(...).nodes */ getNodeByPath: GetNodeByPath; } interface Collection { edges?: Edge[]; nodes?: Node[]; pageInfo: { endCursor?: string | undefined; hasNextPage: boolean; [otherProperties: string]: unknown; }; totalCount?: number; [otherProperties: string]: unknown; } interface CollectionQueryResult { data: TQuery | undefined; error: ApolloError | undefined; loadingRefresh: boolean; loadingNextPage: boolean; loadingInitialContent: boolean; refresh(): void; nextPage(): void; } type GetCollectionByPathFunction = (data: TQuery | undefined) => Collection | undefined; type GetNodeByPath = (data: TSubscription | undefined) => Node | undefined; export declare function useCollectionQuery({ query, queryOptions, getCollectionByPath, subscription, }: UseCollectionQueryArguments): CollectionQueryResult; export declare function isAlreadyUpdated(outputCollection: Collection, newNode: Node): boolean; export {};