Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

awaitRefetchQueries not working? #2267

Closed
nikgraf opened this issue Aug 8, 2018 · 12 comments
Closed

awaitRefetchQueries not working? #2267

nikgraf opened this issue Aug 8, 2018 · 12 comments
Assignees

Comments

@nikgraf
Copy link

nikgraf commented Aug 8, 2018

Intended outcome:

I'm setting awaitRefetchQueries to true and I expected that the refetch queries would be loaded before I'm navigating to the overview page.

          <Mutation
            mutation={addRecipeMutation}
            refetchQueries={[
              {
                query: recipesQuery,
                variables: { vegetarian: false }
              },
              {
                query: recipesQuery,
                variables: { vegetarian: true }
              }
            ]}
            awaitRefetchQueries={true}
          >
            {(addRecipe, { loading, error, client }) => (
              <form
                onSubmit={async evt => {
                  evt.preventDefault();
                  await addRecipe({
                    variables: {
                      recipe: {
                        title: data.title,
                        vegetarian: data.vegetarian
                      }
                    }
                  });
                  navigate("/");
                }}
              >

Actual outcome:

As you can see in the GIF the refetchQueries actually load afterwards.

awaitrefetchqueries2

How to reproduce the issue:

I possibly can add a codesandbox in the future.

Version

From yarn.lock

@hwillson hwillson self-assigned this Aug 9, 2018
@hwillson
Copy link
Member

hwillson commented Aug 9, 2018

Hmm - interesting @nikgraf. I'll take a look at this today. If you're able to put together a quick runnable reproduction for this, that would definitely help get this resolved faster. Thanks!

@hwillson
Copy link
Member

hwillson commented Aug 9, 2018

Don't worry about the repro @nikgraf - I'm able to reproduce the issue. More details shortly.

@hwillson
Copy link
Member

hwillson commented Aug 9, 2018

Wait - the awaitRefetchQueries changes haven't been published yet. See: https://github.com/apollographql/react-apollo/blob/master/Changelog.md#vnext

The documentation updates were published beforehand because they're handled automatically, but the actual code changes aren't in place yet. The good news is that I've verified your scenario is fixed in master. I'll get a new react-apollo version published today. Thanks!

@hwillson
Copy link
Member

hwillson commented Aug 9, 2018

awaitRefetchQueries functionality should now be available in react-apollo 2.1.11. Thanks!

@hwillson hwillson closed this as completed Aug 9, 2018
@nikgraf
Copy link
Author

nikgraf commented Aug 9, 2018

thanks @hwillson 🙌

@s-r-jones
Copy link

Im still seeing this in V 2.4 @hwillson

@mutefiRe
Copy link

mutefiRe commented Feb 12, 2019

@s-r-jones @hwillson same here

@mmayla
Copy link

mmayla commented Mar 11, 2019

Same here

1 similar comment
@nik-lampe
Copy link

Same here

@nikgraf
Copy link
Author

nikgraf commented May 12, 2019

seems to be broken again in the latest version

@Simba14
Copy link

Simba14 commented May 27, 2019

Experiencing the same issue on the latest release. Can this be reopened?

@imekachi
Copy link

I'm on @apollo/react-hooks": "^3.1.3, and still having this issue.

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

8 participants