aws-mobile-appsync-sdk-js: Problem with mutations with appsync client

Hi, I’m currently setting up a new project with AppSync and React and I’m running into problems with mutations. Fetching data works fine but when I try to do any mutation the response somehow crashes. The backend receives the mutation and changes the data, but in the appsync client something goes worng and I get the following errors:

offline-link.js:97 Uncaught TypeError: Cannot read property ‘queryManager’ of undefined at Object.next (offline-link.js:97) at notifySubscription (Observable.js:126) at onNotify (Observable.js:161) at SubscriptionObserver.next (Observable.js:215) at notifySubscription (Observable.js:126) at onNotify (Observable.js:161) at SubscriptionObserver.next (Observable.js:215) at notifySubscription (Observable.js:126) at onNotify (Observable.js:161) at SubscriptionObserver.next (Observable.js:215) at httpLink.js:91

The mutation is executed in the backend and the proper information is submitted back to the browser. But the AppSync Client for some reason can’t handle the response. If I setup an ApolloClient with ‘apollo-boost’ and connect it to the same endpoint everything works as expected. Is there something wrong with my query or does the AppSync client require a diffrent setup?

Some code:

const client = new AWSAppSyncClient({
  url: config.graphqlEndpoint,
  region: config.region,
  auth: {
    type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
    jwtToken: async () => (await Auth.currentSession()).idToken.jwtToken
  }
});

Mutation:

client
  .mutate({
    mutation: gql`
      mutation addManagementArea($name: String!) {
        addManagementArea(name: $name) {
          __typename
          id
          name
        }
      }
    `,
    variables: { name: "test 123" }
  })
  .then(data => console.log("success", data))
  .catch(error => console.error("error", error));

If I’m running the same query with just the ApolloClient and the same setup I get a response back:

const client = new ApolloClient({
  uri: config.graphqlEndpoint,
  request: async operation => {
    operation.setContext({
      headers: {
        authorization: (await Auth.currentSession()).idToken.jwtToken
      }
    });
  }
});

Package.json:

{
  "name": "resido-web-client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "amazon-cognito-identity-js": "2.0.6",
    "apollo-boost": "^0.1.10",
    "aws-amplify": "^0.4.1",
    "aws-appsync": "^1.1.2",
    "aws-appsync-react": "^1.0.17",
    "graphql-tag": "^2.9.2",
    "moment": "^2.22.1",
    "react": "16.4.0",
    "react-apollo": "2.1.4",
    "react-dom": "16.4.0",
    "react-redux": "^5.0.7",
    "react-router-dom": "4.2.2",
    "react-scripts": "1.1.4",
    "react-waypoint": "^8.0.1",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0",
    "uuid": "^3.2.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 5
  • Comments: 18 (2 by maintainers)

Commits related to this issue

Most upvoted comments

@elorzafe can verify that 1.3.4 returns a null, and @deepdish-next fixes this. What’s the planned release date for this?

@micahjonas This appears to be fixed in the “deepdish” version. I just tried it and didn’t face any issues.

yarn add aws-appsync@deepdish aws-appsync-react@deepdish - this is probably unstable, but good enough for my needs at the moment.

We are preparing a new version that has many internal changes, it should address the issues you mentioned before, however the api remains the same.

You can try our latest beta version on @deepdish-next tag (1.3.5-link-effect.2)

I have the same issue. Working my way backwards, I found that the latest version where this works is in version 1.0.22.