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.

Data disappears between two queries of the same type. UI updates with empty props.

See original GitHub issue

I am using react-apollo and the <Query> component.

Intended outcome: Execute two queries (A and B) in series over the same root field (article) and with a shared sub-query (image). There are fewer fields on the image sub-selection in query B than on image in query A. The image id changes upstream between the execution of the two queries, so the data responses will be slightly different for the two queries.

First query:

query A {
  article {
    id
    image {
      id 
      src
    }
  }
}

Later query (triggered after a user interaction):

query B {
  article {
    id
    title
    image {
      id   # This id has changed since query A was executed
    }
  }
}

The <Query> component that is subscribing to query A should either get updated with new data after B is completed, or ignore the data from B if it’s inconsistent with A.

Actual outcome: The query component that is subscribing to A is re-rendered without the data prop.

How to reproduce the issue: https://codesandbox.io/s/0xl9v5znnw

Versions “apollo-cache-inmemory”: “1.2.10” “apollo-client”: “2.4.2” “react-apollo”: “2.1.11”

Possibly related https://github.com/apollographql/apollo-client/issues/3267 https://github.com/apollographql/react-apollo/pull/2003

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

10reactions
oxy88commented, Sep 26, 2018

This is a serious problem

0reactions
joshjgcommented, Mar 8, 2020

@helfer In my mind partialRefetch makes sense as a default if issues like these cannot be mitigated in another way. However, it would be helpful to get some feedback when a scenario like I posted above occurs. A console warning at the least. Currently it fails silently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my data disappear when a subscription goes ...
I got it to work by splitting up my queries as suggested by @nburk. ... this.props.data this.subscription = [subscribeToMore( { document: ...
Read more >
React Query 3: A Guide to Fetching and Managing Data
Need to fetch data in React? Learn about React Query, an excellent server state management library for simplifying your data-fetching needs.
Read more >
How To Handle Async Data Loading, Lazy Loading, and Code ...
In this tutorial, you'll handle asynchronous data in React by creating an app that displays information on rivers and simulates requests to Web ......
Read more >
Data resources in UI Builder
Update Multiple Records; Update Record. Transform. Transform data resources that let you perform transforms. They include: Bind data to ...
Read more >
Understanding common frustrations with React Hooks
These class components, often called container components, execute the side effects and pass props down to these pure stateless component ...
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