diff --git a/src/features/repo-list/index.tsx b/src/features/repo-list/index.tsx index 0bb977c..69ab0ad 100644 --- a/src/features/repo-list/index.tsx +++ b/src/features/repo-list/index.tsx @@ -24,6 +24,14 @@ const RepoList = ({ username }: Props) => { ownerAffiliations: [tabEnum], after, before, + /** + * @variant (!before, !after) => Первый вход, фетчим первые {PAGE_SIZE} + * @variant (after, !before) => След. страница, фетчим след. первые {PAGE_SIZE} + * @variant (!after, before) => Пред. страница, фетчим пред. последние {PAGE_SIZE} + * @variant (after, before) => (невозможна из-за реализации) + */ + first: (!before && PAGE_SIZE) || undefined, + last: (before && PAGE_SIZE) || undefined, }, }); const { pageInfo, totalCount = 0, nodes } = data?.user?.repositories || {}; diff --git a/src/features/repo-list/queries.gen.ts b/src/features/repo-list/queries.gen.ts index bbdd287..8ea8e2f 100644 --- a/src/features/repo-list/queries.gen.ts +++ b/src/features/repo-list/queries.gen.ts @@ -8,6 +8,8 @@ export type ReposQueryVariables = Types.Exact<{ ownerAffiliations?: Types.Maybe>>; after?: Types.Maybe; before?: Types.Maybe; + first?: Types.Maybe; + last?: Types.Maybe; }>; @@ -15,10 +17,10 @@ export type ReposQuery = { readonly user?: Types.Maybe<{ readonly id: string, re export const ReposDocument = gql` - query Repos($login: String!, $ownerAffiliations: [RepositoryAffiliation], $after: String, $before: String) { + query Repos($login: String!, $ownerAffiliations: [RepositoryAffiliation], $after: String, $before: String, $first: Int, $last: Int) { user(login: $login) { id - repositories(ownerAffiliations: $ownerAffiliations, first: 30, orderBy: {field: PUSHED_AT, direction: DESC}, after: $after, before: $before) { + repositories(ownerAffiliations: $ownerAffiliations, orderBy: {field: PUSHED_AT, direction: DESC}, after: $after, before: $before, first: $first, last: $last) { pageInfo { endCursor startCursor @@ -58,6 +60,8 @@ export const ReposDocument = gql` * ownerAffiliations: // value for 'ownerAffiliations' * after: // value for 'after' * before: // value for 'before' + * first: // value for 'first' + * last: // value for 'last' * }, * }); */ diff --git a/src/features/repo-list/queries.gql b/src/features/repo-list/queries.gql index 576f778..f288f7d 100644 --- a/src/features/repo-list/queries.gql +++ b/src/features/repo-list/queries.gql @@ -1,7 +1,7 @@ -query Repos ($login: String!, $ownerAffiliations: [RepositoryAffiliation], $after: String, $before: String) { +query Repos ($login: String!, $ownerAffiliations: [RepositoryAffiliation], $after: String, $before: String, $first: Int, $last: Int) { user(login: $login) { id - repositories(ownerAffiliations: $ownerAffiliations, first: 30, orderBy: {field: PUSHED_AT, direction: DESC}, after: $after, before: $before) { + repositories(ownerAffiliations: $ownerAffiliations, orderBy: {field: PUSHED_AT, direction: DESC}, after: $after, before: $before, first: $first, last: $last) { pageInfo { endCursor startCursor