1. 15
    Use fetchMore and merge field policies to dynamically load more items into a list
    7m 48s

Use fetchMore and merge field policies to dynamically load more items into a list

Share this video with your friends

Send Tweet

Lists of notes can get very big. We don't want to load all existing notes on the database every time the user loads the app. We'd like to re-create the Twitter timeline experience, and only when the user scrolls to the bottom, then load a few more notes. For this, we'll start off by looking at the fetchMore utility, that is provided by the useQuery hook, to trigger loading of more notes from the server. Then, we'll look at defining a merge field policy, to define how these new loaded notes should be combined with the existing notes. Finally, we'll look at specifying keyArgs for queries, and how it helps us define by which variables to key certain queries in the cache.