Welcome to mirror list, hosted at ThFree Co, Russian Federation.

utils.js « dependency_proxy « packages_and_registries « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e6b97fac89697273c0af048466a6f2bb7b14a792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { GRAPHQL_PAGE_SIZE } from './constants';

const getNextPageParams = (cursor) => ({
  after: cursor,
  first: GRAPHQL_PAGE_SIZE,
});

const getPreviousPageParams = (cursor) => ({
  first: null,
  before: cursor,
  last: GRAPHQL_PAGE_SIZE,
});

export const getPageParams = (pageInfo = {}) => {
  if (pageInfo.before) {
    return getPreviousPageParams(pageInfo.before);
  }

  if (pageInfo.after) {
    return getNextPageParams(pageInfo.after);
  }

  return {};
};