question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fetchMore's updateQuery option receives the wrong variables

See original GitHub issue

The updateQuery method passed to ObservableQuery.fetchMore is receiving the original query variables instead of the new variables that it used to fetch more data.

This is problematic not so much because it breaks the updateQuery method contract (which is bad, but clearly doesn’t seem to impact many people), but rather because when the results from fetchMore are written to the store in writeQuery, the old variables are used. This cases issues, say, if you were using an @include directive and the variable driving its value changes.

Repro is available here: https://github.com/jamesreggio/react-apollo-error-template/tree/repro-2499

Expected behavior

nextResults.variables shows petsIncluded: true and the pets list gets displayed.

Actual behavior

nextResults.variables shows petsIncluded: null and the pets list is not displayed because the write never happens due to the @include directive being evaluated with the old variables.

Version

  • apollo-client@2.0.1

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:30
  • Comments:52 (13 by maintainers)

github_iconTop GitHub Comments

70reactions
jamesreggiocommented, Dec 4, 2017

Here’s a GIF to keep this open.

gif

12reactions
Billy-commented, Apr 16, 2018

@jbaxleyiii any update on this at all please?

Kind regards,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apollo Graphql fetchMore, updateQuery does not update ...
I'm not sure why, but setting a fetchPolicy for Apollo will do the job const client = new ApolloClient({ link: authLink.concat(httpLink), ...
Read more >
Core pagination API - Apollo GraphQL Docs
By default, fetchMore executes a query with the exact same shape and variables as your original query. You can pass new values for...
Read more >
GraphQL Pagination with Apollo Client in React
The fetchMore() function performs the query from the initial request, and takes a configuration object, which can be used to override variables. With...
Read more >
Apollo pagination tutorial: using fetchMore()
const { data, loading, error, refetch, fetchMore } = useQuery(QUERY, { variables, fetchPolicy, errorPolicy: 'all', }, );. The fetchMore function ...
Read more >
Reactive Query
query : GraphQL document (can be a file or a gql string). variables : Object ... options) is a hook called when there...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found