apollo: Vue-Apollo v4 documentation doesn't follow Apollo Client v3 documentation
In the documentation regarding pagination, it guides the user to use updateQuery
. However, in ApolloClient v3 this is deprecated with a warning that it will be removed in the next major version.
https://v4.apollo.vuejs.org/guide-composable/pagination.html
The updateQuery callback for fetchMore is deprecated, and will be removed
in the next major version of Apollo Client.
Please convert updateQuery functions to field policies with appropriate
read and merge functions, or use/adapt a helper function (such as
concatPagination, offsetLimitPagination, or relayStylePagination) from
@apollo/client/utilities.
The field policy system handles pagination more effectively than a
hand-written updateQuery function, and you only need to define the policy
once, rather than every time you call fetchMore.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 4
- Comments: 15
Got same issue trying to use TypePolicies for vue-composable queries and it doesn’t seem to “see” TypePolicies for my field. In contrary, I used resolvers (deprecated) with the same query and they work.
It seems I will have to use deprecated resolvers until vue-composables will be compatible with TypePolicies 😦
@MechJosh0 I started the project with Apollo Client 3, and it worked great until now.
As you can see in this screenshot the quotes are
PaginatedItems
type, but I’ve tried that too, in the typePolicies like that and its not working:Here is my query:
and this is what I get back:
I have no idea why it is not working. Can you please help me?
Maybe I just wait till the Vue Apollo 4 docs gets into better shape… Hope I will find answers there specific to VueJS. However I started to feeling worried about this library. The last major version was months ago… 😦
@Gyurmatag
As per their Apollo Client 3 release announcement (and the console warning), we no longer want
updateQuery
on thefetchMore
function, so you should go ahead and remove it entirely.Note: You’ll notice how I imported
variables
from Vue Apollo as I discovered this to be very helpful withfetchMore
for pagination andrefetch
for searching and ordering. This will obviously be up to you if you and your use case if you find it helpful or not.You should then read about offset pagination helpers and keyArgs to learn how to implement the new pagination methods.
If you can use Apollo Clients pagination helpers, you should. Otherwise, you will need to create the pagination logic yourself: