Query doesn't update when data changes
See original GitHub issueContext:
Hi, one of my endpoints is very slow; so I made the relevant resolver return early; on the client I poll for a subset of the data which I know will soon change.
const INSTANCE_LIST = gql`
query {
viewer {
id
instances {
id
createdAt
instanceType
prettyName
hashCode
url
color
primaryStorageSize
startupStage
startupDnsComplete
}
}
}
`
const STARTUP_STAGE_ONLY = gql`
query {
viewer {
instances {
id
startupStage
startupDnsComplete
}
}
}
`
const InstanceList = () => (
<Query query={INSTANCE_LIST}>
{({data, refetch}) => {
const instances = data?.viewer?.instances || []
const inFlux = instances.some(i => {
return i.startupStage !== 'done' || !i.startupDnsComplete
})
return (
<>
{inFlux && (
<Query query={STARTUP_STAGE_ONLY} pollInterval={1500}>
{() => null}
</Query>
)}
{instances
.slice()
.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
.map((instance, index) => (
<OneInstance
key={instance.id}
instance={instance}
index={index}
/>
))}
</>
)
}}
</Query>
)
Intended outcome:
When the data changes, the parent <Query />
component will re-render and have up-to-date information.
Actual outcome:
Although the client cache updates, the parent <Query />
component keeps rendering stale data, even after remounting.
How to reproduce the issue:
It’ll take me a little time to put an example together, which I can do. But it’d be great to know if this is already a known issue before investing the time.
Versions
System:
OS: Linux 4.15 Ubuntu 16.04.4 LTS (Xenial Xerus)
Binaries:
Node: 10.1.0 - ~/.nvm/versions/node/v10.1.0/bin/node
npm: 6.1.0 - ~/.nvm/versions/node/v10.1.0/bin/npm
Browsers:
Chrome: 67.0.3396.99
Firefox: 61.0.1
npmPackages:
apollo-server: 2.0.0-rc.10 => 2.0.0-rc.10
apollo-server-express: 2.0.0-rc.10 => 2.0.0-rc.10
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Access Update query doesn't update the data - Stack Overflow
In a quick test, the access query designer for a non-passthrough update query generated. UPDATE dbo_Available SET dbo_Available.
Read more >Excel: Queries and Connections: Data does not update after
Hey, I have a problem with a data querie/ connection in Excel not refreshing (not updating the values), even though it says it...
Read more >sql server - UPDATE performance where no data changes
The method shown in that answer doesn't filter out rows that exist yet do not need to be updated. That portion could be...
Read more >Solved: Power Query Data is updating in PQ Editor, but not...
Solved: I have a Power Query through Excel. I haven't change anything to this file, except the same data source was updated with...
Read more >Excel Pivot Table Refresh Steps and Fixes - Contextures
When you change the information in a pivot table's source data, the pivot table doesn't automatically show the latest information.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Woah, named queries and devtools? You’re blowing my mind with this whole new world of stuff I didn’t know about. 😍
The devtools were reporting “There is a network error: {“type”:“WriteError”}”, but without any details. The error seemed to come from here, so I opened up the file inside node_modules, added a console.log and tried again. Here’s the error I got:
With this guidance I realised
id
was missing from the selection set forviewer
, added it & the issue was resolved!The problem then, is this error wasn’t very visible; and once found, there weren’t enough details to help diagnose the issue without editing node_modules. The error was essentially silent.
Try adding an
id
toviewer
so Apollo can differentiateviewers
that are in the store? This worked for me anyway.