@urql/exchange-graphcache
Version:
A normalized and configurable cache exchange for urql
76 lines (69 loc) • 3.25 kB
TypeScript
import { Resolver } from './urql-exchange-graphcache-chunk.js';
type MergeMode$1 = 'outwards' | 'inwards';
/** Input parameters for the {@link relayPagination} factory. */
interface PaginationParams$1 {
/** Flip between inwards and outwards pagination.
*
* @remarks
* This is only relevant if you’re querying pages using forwards and
* backwards pagination at the same time.
* When set to `'inwards'`, its default, pages that have been queried
* forward are placed in front of all pages that were queried backwards.
* When set to `'outwards'`, the two sets are merged in reverse.
*/
mergeMode?: MergeMode$1;
}
/** Creates a {@link Resolver} that combines pages that comply to the Relay pagination spec.
*
* @param params - A {@link PaginationParams} configuration object.
* @returns the created Relay pagination {@link Resolver}.
*
* @remarks
* `relayPagination` is a factory that creates a {@link Resolver} that can combine
* multiple pages on a field that complies to the Relay pagination spec into a single,
* combined list for infinite scrolling.
*
* This resolver will only work on fields that return a `Connection` GraphQL object
* type, according to the Relay pagination spec.
*
* Hint: It's not recommended to use this when you can handle infinite scrolling
* in your UI code instead.
*
* @see {@link https://urql.dev/goto/docs/graphcache/local-resolvers#relay-pagination} for more information.
* @see {@link https://urql.dev/goto/docs/basics/ui-patterns/#infinite-scrolling} for an alternate approach.
*/
declare const relayPagination: (params?: PaginationParams$1) => Resolver<any, any, any>;
type MergeMode = 'before' | 'after';
/** Input parameters for the {@link simplePagination} factory. */
interface PaginationParams {
/** The name of the field argument used to define the page’s offset. */
offsetArgument?: string;
/** The name of the field argument used to define the page’s length. */
limitArgument?: string;
/** Flip between forward and backwards pagination.
*
* @remarks
* When set to `'after'`, its default, pages are merged forwards and in order.
* When set to `'before'`, pages are merged in reverse, putting later pages
* in front of earlier ones.
*/
mergeMode?: MergeMode;
}
/** Creates a {@link Resolver} that combines pages of a primitive pagination field.
*
* @param options - A {@link PaginationParams} configuration object.
* @returns the created pagination {@link Resolver}.
*
* @remarks
* `simplePagination` is a factory that creates a {@link Resolver} that can combine
* multiple lists on a paginated field into a single, combined list for infinite
* scrolling.
*
* Hint: It's not recommended to use this when you can handle infinite scrolling
* in your UI code instead.
*
* @see {@link https://urql.dev/goto/docs/graphcache/local-resolvers#simple-pagination} for more information.
* @see {@link https://urql.dev/goto/docs/basics/ui-patterns/#infinite-scrolling} for an alternate approach.
*/
declare const simplePagination: ({ offsetArgument, limitArgument, mergeMode, }?: PaginationParams) => Resolver<any, any, any>;
export { relayPagination, simplePagination };