React-apollo: awaitRefetchQueries not working?

Created on 8 Aug 2018  路  12Comments  路  Source: apollographql/react-apollo

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

bug confirmed

Most helpful comment

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

All 12 comments

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!

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

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!

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

thanks @hwillson 馃檶

Im still seeing this in V 2.4 @hwillson

@s-r-jones @hwillson same here

Same here

Same here

seems to be broken again in the latest version

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

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

Was this page helpful?
0 / 5 - 0 ratings