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.

previousData is lost when useLazyQuery's executor is called

See original GitHub issue

Intended outcome: Extraneous calls of the callback returned by useLazyQuery should have no effect.

Actual outcome: Calling the callback always sets the previousData to undefined. To avoid this behaviour, the user has to keep track of “has the callback been called already?”

How to reproduce the issue: Here is a codesandbox which should demonstrate the issue in the console tab. There’s a variable you can tweak to enable/disable the workaround.

Versions

  System:
    OS: macOS 10.15.7
  Binaries:
    snip
  Browsers:
    Chrome: 87.0.4280.67
    Firefox: 80.0.1
    Safari: 14.0
  npmPackages:
    @apollo/client: ^3.3.1 => 3.3.1
    apollo: ^2.31.1 => 2.31.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
tpictcommented, Jul 13, 2021

We’ve been thinking in AC4 of deprecating useLazyQuery(), insofar as it might just be easier to call the core client APIs directly in a useEffect when you need fine-grained control over when a query is made. Would that make people in this issue upset?

My initial thought is “no”, but could you give an example of what the useEffect callback would look like? I agree that the distinction between execute and refetch has always felt like a wart, but I get the impression that useLazyQuery is very widely used, so its removal might be upsetting to people if the replacement is much less ergonomic. Thanks for looking into this!

3reactions
hwillsoncommented, Nov 8, 2021

This should now be resolved in @apollo/client@3.5.0. Let us know if you notice any issues. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Queries - Apollo GraphQL Docs
First, we'll create a GraphQL query named GET_DOGS . ... The useLazyQuery hook is perfect for executing queries in response to events besides...
Read more >
What Happens When An Estate Executor Loses Capacity?
If an executor is losing capacity or incapacitated, it is wise to ask him or her to consider resigning from the role voluntarily...
Read more >
Guidelines for Individual Executors & Trustees
After an individual's death, his or her assets will be gathered, business affairs settled, debts paid, necessary tax returns filed, and assets distributed...
Read more >
Executor of Estate: What Do They Do? - Forbes
If you refuse, an alternate or contingent executor named in the will (or administrator appointed by the probate court judge) will handle the ......
Read more >
Fiduciary of an Estate | NY CourtHelp - Unified Court System
After a person dies, their property (also called the estate) must be ... to the person who died or the named Executor if...
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