Skip to content

Commit

Permalink
fix next page calc
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercactapus committed Nov 1, 2022
1 parent dab6149 commit 7e6063d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions graphql2/graphqlapp/messagelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,18 @@ func (q *Query) MessageLogs(ctx context.Context, opts *graphql2.MessageLogSearch

searchOpts.Limit++
logs, err := q.NotificationStore.Search(ctx, &searchOpts)
hasNextPage := len(logs) == searchOpts.Limit
searchOpts.Limit-- // prevent confusion later
if err != nil {
return nil, err
}

conn = new(graphql2.MessageLogConnection)
conn.PageInfo = &graphql2.PageInfo{
HasNextPage: len(logs) == searchOpts.Limit,
HasNextPage: hasNextPage,
}

if conn.PageInfo.HasNextPage {
if hasNextPage {
last := logs[len(logs)-1]
searchOpts.After.CreatedAt = last.CreatedAt
searchOpts.After.ID = last.ID
Expand Down

0 comments on commit 7e6063d

Please sign in to comment.