apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

"Cursor-based pagination" documentation include invalid examples for merge & read #12062

Open cabillin opened 2 months ago

cabillin commented 2 months ago

Issue Description

https://www.apollographql.com/docs/react/pagination/cursor-based/ provides merge & read functions (to optimize the cache during paging while also excluding the paging args via keyArgs) that are invalid.

The functions assume the incoming data is a collection, but it is actually a Connection. image

Link to Reproduction

https://github.com/cabillin/react-apollo-issues/tree/docs_paging_invalid

Reproduction Steps

npm start on attached repo => observe it is incorrectly showing {"allFilms":[]}

comment out keyArgs, merge, & read => observe the data coming back correctly from the cache

@apollo/client version

3.11.4