1

I'm using the basic client configuration from the example on the first page of https://github.com/awslabs/aws-mobile-appsync-sdk-js 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}>
    <App/>
  </ApolloProvider>
</Provider>

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

Edit Additional information. This is happening in a react-native program created with Expo. Reloading the program by shaking the device and selecting "Reload" results in the above behavior. However, restarting Expo, and running the program again causes the query to be refetched as desired.

reggie3
  • 1,018
  • 2
  • 15
  • 22
  • Did you ever solve this? I'm seeing something very similar (but in a node app). – macbutch Jul 12 '18 at 13:34
  • No, I didn't. I've since moved on to Amazon's GraphQL client implementation which so far has been working like I expected it to. It's called API, it works with REST also, and it doesn't require using Amazon Webb Services. It works for me since I don't need Apollo to store my local state. https://aws.github.io/aws-amplify/media/api_guide – reggie3 Jul 12 '18 at 23:02

0 Answers0