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

Broken resetStore for queries with skip #7113

Closed
BlobRage0 opened this issue Oct 2, 2020 · 3 comments · Fixed by #7146
Closed

Broken resetStore for queries with skip #7113

BlobRage0 opened this issue Oct 2, 2020 · 3 comments · Fixed by #7146

Comments

@BlobRage0
Copy link

Hi all! I updated from apollo-client 2.6 to @apollo/client 3.2.2 and had some unexpected behavior.

Intended outcome:
Query with flag skip=true on call client.resetStore() shouldn't be refetched

Actual outcome:
Query with flag skip=true on call client.resetStore() refetches

How to reproduce the issue:

  1. create query, set flag skip=true
  2. call client.resetStore()

Versions
System:
OS: macOS 10.15.5
Binaries:
Node: 14.11.0 - /usr/local/bin/node
npm: 6.14.8 - /usr/local/bin/npm
Browsers:
Chrome: 85.0.4183.121
Firefox: 80.0.1
Safari: 13.1.1
npmPackages:
@apollo/client: ^3.2.2 => 3.2.2
npmGlobalPackages:
apollo: 2.30.3

@joncursi
Copy link

joncursi commented Oct 7, 2020

I am getting the same error. Has anyone found a solution to this one?

Here's how I am able to reproduce:

  1. Create a query where skip={true}, e.g. a scenario where the required query variables are missing:
      const id = undefined;

      <Query
        query={gql`
            query MyQuery($id: String!) {
              myThing(id: $id) {
                _id
                someProperty
                ...
              }
            }
        `}
        skip={!id}
        variables={{
          id: id,
        }}
      >
        ...
      </Query>
  1. Observe that this query does properly skip itself when the component initially loads.

  2. Call client.resetStore()

  3. Observe that the skipped query is now executed, and the GraphQL API throws an error (because in this case, the query is missing required variables and should never have been executed):

Variable `id` of type `String!` must not be null

@joshjg
Copy link
Contributor

joshjg commented Oct 9, 2020

Appears to have been caused by #6999

@benjamn
Copy link
Member

benjamn commented Oct 13, 2020

This should be fixed in @apollo/[email protected], thanks to #7146 by @joshjg.

@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.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants