Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Adds cursorFrom function in step "Paginated queries" #825

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/source/tutorial/resolvers.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,16 @@ module.exports = {
pageSize,
results: allLaunches
});

const cursorFrom = items => items[items.length - 1].cursor

return {
launches,
cursor: launches.length ? launches[launches.length - 1].cursor : null,
cursor: launches.length ? cursorFrom(launches) : null,
// if the cursor of the end of the paginated results is the same as the
// last item in _all_ results, then there are no more results after this
hasMore: launches.length
? launches[launches.length - 1].cursor !==
allLaunches[allLaunches.length - 1].cursor
? cursorFrom(launches) !== cursorFrom(allLaunches)
: false
};
},
Expand Down