Strange Caching Behavior Using AWS AppSync

I am trying to integrate AWS AppSync into my Expo application. The problem described below happens whenever I reload the program by shaking the device and selecting “Reload”. However, a force shutdown via my Android device, restarting Expo, and then running the program again results in the desired behavior; a refetch of the original query.

I’m not sure if this is an Expo problem or an AWS AppSync problem, so I’ve posted this question here and in the aws-mobile-appsync-sdk-js issue tracker here

I’m using the basic client configuration from the example on the first page of aws-mobile-appsync-sdk-js library [][1] repo:

const client = new AWSAppSyncClient({
  url: appSyncConfig.graphqlEndpoint,
  region: appSyncConfig.region,
  auth: {
    type: appSyncConfig.authenticationType,
    apiKey: appSyncConfig.apiKey,

But without the <Rehydrated> component, and with a Redux <Provider> component. The highest level parent component is wrapped like this:

<Provider store={store}>
  <ApolloProvider client={client}>

I’ve tried swapping the order for the Provider and ApolloProvider, but that did not change the result.

The problem is that the query runs successfully one time but, doesn’t run again.
The AppSync’s CloudWatch logs show the initial successful query, but show no further query attempts. That leads me to believe that the problem is due to something on the client.

I’ve set the fetchPolicy on the query to 'network-only' with no results:

const mapDataToProps = graphql(GET_ALL_STORIES, {
  name: 'getAllStories',
  options: { fetchPolicy: 'network-only' }

I’ve confirmed that the named query “getAllStories” does actually exist on the component by inspecting the component in the Chrome debugger. The query props NetworkStatus and loading properties remain at 1 and true the entire time, and no response is ever received.

I am currently using the following versions of relevant libraries:
aws-appsync: 1.0.17
Apollo-client: 2.2.8
react-Apollo: 2.1.3
redux: 3.6.0

Additional information. This is happening in a react-native program created with Expo.

Hi @reggie3! I don’t know much about the AppSync library, so hard to say exactly what’s going wrong. I think right now there are a lot of layers that could be caching so it might be best to go into the library code in node_modules and add some logs or breakpoints. Also might be useful to isolate some code that reproduces this and then try it in a non-Expo app.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.