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

awaitRefetchQueries not functioning as expected #2426

Closed
tyhopp opened this issue Sep 27, 2018 · 2 comments
Closed

awaitRefetchQueries not functioning as expected #2426

tyhopp opened this issue Sep 27, 2018 · 2 comments

Comments

@tyhopp
Copy link

tyhopp commented Sep 27, 2018

Intended outcome:
awaitRefetchQueries set to true will ensure refetchQueries() is completed before the mutation completes and onCompleted() fires.

Expected completion order:

  1. refetchQueries()
  2. mutate()
  3. onCompleted(), navigates to new screen

Actual outcome:
Actual completion order:

  1. mutate()
  2. onCompleted(), navigates to new screen
  3. refetchQueries()
<Mutation
	mutation={DELETE_TRIP_DECK}
	variables={{ deckId: `usa` }}
optimisticResponse={{
	deleteTripDeck: null,
}}
refetchQueries={() => [
	{
		query: GET_USER_INFO,
		variables: { username: username },
	},
]}
awaitRefetchQueries={true}
onCompleted={() => goBack()}>
	{(
		deleteTripDeck,
		{ loading, error, data }
	) => {
		if (error) throw error
		return (
			<Button onPress={() => deleteTripDeck()}>
				<Text>Delete trip</Text>
			</Button>
		)
	}}
</Mutation>

Theory: Given we're not using ApolloClient directly but instead using AWSAppSyncClient, which is built on top of Apollo, I'm wondering whether both react-apollo and apollo-client required by AWSAppSyncClient must be updated #3169 so that awaitRefetchQueries will function properly.

Update - package-lock.json contains apollo-client@2.3.7, and that release does contain awaitRefetchQueries functionality, seen here.awaitRefetchQueries was supported as of 2.3.6, changelog reference.

Package.json:

"dependencies": {
    "@expo/react-native-responsive-image": "^2.0.0",
    "@expo/samples": "2.1.1",
    "apollo-cache-inmemory": "^1.2.8",
    "apollo-cache-persist": "^0.1.1",
    "apollo-link": "^1.2.2",
    "apollo-link-state": "^0.4.1",
    "aws-amplify": "^1.0.4",
    "aws-amplify-react-native": "^1.0.4",
    "aws-appsync": "^1.3.2",
    "aws-appsync-react": "^1.1.2",
    "expo": "^28.0.0",
    "graphql-tag": "^2.9.2",
    "lodash.capitalize": "^4.2.1",
    "react": "16.3.1",
    "react-apollo": "^2.1.11",
    "react-native": "https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz",
    "react-native-indicators": "^0.13.0",
    "react-native-keyboard-aware-scroll-view": "^0.7.2",
    "react-native-modal": "^6.5.0",
    "react-native-swiper": "^1.5.13",
    "react-navigation": "^2.17.0",
    "styled-components": "^3.4.1",
    "uuid": "^3.3.2"
  },

Related: #2267

Unable to provide video/screenshot/reproduction because the project isn't public just yet, but thought I'd try an issue in case the above is enough to help get through this. Thanks!

@tyhopp
Copy link
Author

tyhopp commented Sep 27, 2018

Update - Fixed one issue, awaitRefetchQueries shipped in the August release,react-apollo@2.1.11, and mine was at react-apollo-2.1.9, the July release. Changelog reference.

@hwillson any ideas on this - we're launching soon and any insight would be very appreciated!

@tyhopp
Copy link
Author

tyhopp commented Oct 6, 2018

Closing due to no response or solution found. For those reading I ended up just leaving the code above and manually calling refetch in the navigated-to component.

@tyhopp tyhopp closed this as completed Oct 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant