While I was working on 🎨 I had to implement pagination at some point. No one wants to load a ton of color palettes at once. However I really like the lazy load approach instead of a classic pagination. Colour Hunt 💪 Preparation is build with Nuxt.js, Graph.cool and . The stack is a dream for rapid development as you don’t need to fiddle around with a backend. The idea behind Colour Hunt is, that people can create and share color palettes. However you can use this techniques for all kind of graphql nodes. Most examples are using the good old Blog example and posts. Colour Hunt vue-apollo So let’s take a look at our GraphQL query: Colour Hunt example query Lets say we have a simple query like this. Just query all palettes that are available and order them by a variable. And our vue component would look like this: Vue component with query We simply load our query, and vue-apollo does all the magic behind the scenes. And we just iterate over our query results. And render the color-palette component. 📝 Pagination We now need to add two arguments to our query. The argument which defines the where the query will start and the argument which defines the or how many element you want to query. And we also need to know how many elements there are. So we utilize the query. So our new query will look like this: skip offset first limit _meta New query with first and skip arguments Now our GraphQL query is ready. And we need to update the Vue component. First we need to update our data. Because we added the to our query. totalCount The is quite important, because we need it to check if there are more palettes to load. If we loaded all palettes, we should not fetch again. We simply add a that will tell us, if we can fetch more. And we can use it, as a condition for our button. totalCount computed property Load More Updated data and computed property Now we need to update our vue-apollo query and add the missing variables. We should at first create a new variable which holds our number of items we want to fetch. For example which I created as a local const variable. You could also use a separate file like constants.js where you save all this kind of constants. So you can change it in one place. PALETTES_PER_PAGE Now it becomes a bit tricky. Because vue-apollo automatically map your query result to your local data model. But we have two returned objects. First and second . I guess you could also execute the query twice, but this seems to me like a code smell. allPalettes totalCount Instead we can use the method which comes with vue-apollo. We simply grab the totalCount and assign it to our local totalCount. result() Now lets create our button which will fetch more entries. Simple as that we just add a render condition, which is our computed property. And as we have our loading state, we can change the button text, depending on if it is loading or not. And on a click we call our method, which we will create in a second. loadMore() ⚡️ Updating the query Now comes the fun part. We need to update our query and fetch more. Vue-apollo comes with a build-in method for that. In our method we just need to call loadMore() .$apollo.queries.allPalettes.fetchMore({variables: {skip: .allPalettes.length}}) this this So you remember what the argument is doing? Right, it is setting an . In our initial query we set and to which equals 10. So we are not skipping anything, and loading the first 10 palettes. Now we fetchMore and skip the first 10 palettes. Because is now 10. skip offset skip: 0 first PALETTES_PER_PAGE this.allPalettes.length` However this is not enough. We also have to update our query in the cache. Which is quite simple: We are checking if there are if not, we are returning the . Otherwise we append the new palette results to the old one with Object.assign() and the spread operator. If you have trouble following, it is always helpful to check out the structure of the apollo cache with the fetchMoreResults previousResults apollo chrome plugin 🎉 Final Result And thats actually it! We implemented lazy loading of palettes in just a few lines of code. And here is the final result: I am building in public and you can follow the progress on . I am also live streaming the development from time to time. Colour Hunt WIP