Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watchQuery triggers network request for other watchQueries using same query document but diffrent variables #8020

Closed
jakubnavratil opened this issue Apr 22, 2021 · 3 comments

Comments

@jakubnavratil
Copy link

jakubnavratil commented Apr 22, 2021

Running 2 watchQuery requests causes 3 network requests. Second query retriggers first one. Both queries are using same document but diffrent variable.

    this.apollo
      .watchQuery<Roof, RoofVariables>({
        query: roofQuery,
        variables: {
          id: '2',
        },
        fetchPolicy: 'network-only',
      })
      .valueChanges.subscribe((v) => {
        console.log(v);
      });

    this.apollo
      .watchQuery<Roof, RoofVariables>({
        query: roofQuery,
        variables: {
          id: '3',
        },
        fetchPolicy: 'network-only',
      })
      .valueChanges.subscribe((v) => {
        console.log(v);
      });

image

Intended outcome:

Just two queries run.

Actual outcome:

Looks like result returning for second query retriggers first one.

How to reproduce the issue:

https://stackblitz.com/edit/apollo-watch-query-infinite-zhiw6w?file=index.js

Versions

System:
    OS: Windows 10 10.0.18362
  Binaries:
    Node: 12.9.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - D:\www\animatec-ng\animatec-crm-client\node_modules\.bin\yarn.CMD
    npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 89.0.4389.114
    Edge: Spartan (44.18362.449.0)
  npmPackages:
    @apollo/client: ^3.0.0 => 3.3.15 
    apollo: ^2.32.5 => 2.32.5 
    apollo-angular: ^2.4.0 => 2.4.0 
@benjamn
Copy link
Member

benjamn commented Apr 22, 2021

@jakubnavratil Thanks to your reproduction, I can confirm this was fixed in @apollo/client@3.4.0-beta.4, likely by PR #7439. We're currently on @apollo/client@3.4.0-beta.23 (release candidate soon!), if you want to try updating.

@jakubnavratil
Copy link
Author

Wow, amazing work! Thank you very much 😄

@hwillson
Copy link
Member

Apollo Client 3.4 is launching soon (we're in RC now). Thanks!

@hwillson hwillson removed this from the MM-2021-06 milestone Jul 29, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants