UNPKG

@stackend/api

Version:

JS bindings to api.stackend.com

68 lines 2.1 kB
export interface GraphQLListNode<T> { node: T; } export interface GraphQLList<T> { edges: Array<GraphQLListNode<T>>; } export interface PaginatedGraphQLListNode<T> { node: T; cursor: string; } export interface PageInfo { hasNextPage: boolean; hasPreviousPage: boolean; } export interface PaginatedGraphQLList<T> { edges: Array<PaginatedGraphQLListNode<T>>; pageInfo: PageInfo; } export interface PaginatedGraphQLRequest { first?: number; after?: string; last?: number; before?: string; } /** * Create a request to the next page * @param req * @param after * @param first, if not present taken from req.last or defaults to 10 */ export declare function nextPage(req: PaginatedGraphQLRequest, after: string, first?: number): PaginatedGraphQLRequest; /** * Create a request to the previous page * @param req * @param before * @param last, if not present taken from req.first or defaults to 10 */ export declare function previousPage(req: PaginatedGraphQLRequest, before: string, last?: number): PaginatedGraphQLRequest; /** * Get the next cursor for a list, or null, if not available * @param list */ export declare function getNextCursor(list: PaginatedGraphQLList<any>): string | null; /** * Get the previous cursor for a list, or null, if not available * @param list */ export declare function getPreviousCursor(list: PaginatedGraphQLList<any>): string | null; /** * Iterate all list nodes * @param list * @param apply */ export declare function forEachGraphQLList<T>(list: GraphQLList<T>, apply: (item: T) => void): void; /** * Map each node of a graph ql list * @param list * @param apply */ export declare function mapGraphQLList<U, T>(list: GraphQLList<T>, apply: (item: T, index: number) => U): U[]; /** * Convert a js object into graphql format query * @param o */ export declare function toQueryParameters(o: any): string; export declare function _arrayToQueryParameters(a: Array<any>): string; export declare function _objectToQueryParameters(o: Record<string, any>): string; //# sourceMappingURL=graphql.d.ts.map