@trackunit/react-graphql-hooks 0.0.12-alpha-d54f3828a2.0 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -9,13 +9,25 @@ export type PaginationQuery<TData> = {
|
|
|
9
9
|
lastFetchedData?: TData;
|
|
10
10
|
pagination: RelayTableSupport;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export interface PaginationQueryProps<TData, TVariables extends ApolloClient.OperationVariables = ApolloClient.OperationVariables> extends ApolloClient.LazyQueryHookOptions<TData, TVariables> {
|
|
13
|
+
/**
|
|
14
|
+
* A function that is used to update the query results with new data.
|
|
15
|
+
*
|
|
16
|
+
* @param previous The previous data from the query, which can be undefined if no previous data exists.
|
|
17
|
+
* @param newData The new data to merge with the previous data.
|
|
18
|
+
* @returns an object containing the merged data, with an optional pageInfo field of type RelayPageInfo or null.
|
|
19
|
+
*/
|
|
13
20
|
updateQuery: (previous: TData | undefined, newData: TData) => {
|
|
14
21
|
data: TData;
|
|
15
22
|
pageInfo?: RelayPageInfo | null;
|
|
16
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* A number specifying the size of each page of data.
|
|
26
|
+
* This is an optional field.
|
|
27
|
+
* If not specified, the default page size is 50.
|
|
28
|
+
*/
|
|
17
29
|
pageSize?: number;
|
|
18
|
-
}
|
|
30
|
+
}
|
|
19
31
|
/**
|
|
20
32
|
* This hook is used to fetch data from a GraphQL query and support pagination, it will help maintain the data and the pagination.
|
|
21
33
|
*
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ApolloClient from "@apollo/client";
|
|
2
|
+
import { PaginationQueryProps } from "./usePaginationQuery";
|
|
3
|
+
export interface UsePaginationQueryDemoComponentProps<TData, TVariables extends ApolloClient.OperationVariables> extends PaginationQueryProps<TData, TVariables> {
|
|
4
|
+
document: ApolloClient.TypedDocumentNode<TData, TVariables>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The `usePaginationQuery` Hook provides pagination when fetching data
|
|
8
|
+
*
|
|
9
|
+
* It returns an object containing methods and values related to pagination.
|
|
10
|
+
*/
|
|
11
|
+
export declare const UsePaginationQueryDemoComponent: <TData, TVariables extends ApolloClient.OperationVariables>({ document, variables, pageSize, updateQuery, }: UsePaginationQueryDemoComponentProps<TData, TVariables>) => JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { UsePaginationQueryDemoComponent } from "./usePaginationQuery.demo";
|
|
3
|
+
type Story = StoryObj<typeof UsePaginationQueryDemoComponent>;
|
|
4
|
+
declare const meta: Meta<typeof UsePaginationQueryDemoComponent>;
|
|
5
|
+
export default meta;
|
|
6
|
+
export declare const packageName: () => JSX.Element;
|
|
7
|
+
export declare const Default: Story;
|