question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems after rebuilding node_modules with latest npm packages

See original GitHub issue

Rebuilt my react native project’s node modules folder and re-ran npm install. Now I’m seeing some problems that were non-existent previously

  1. On Mutate, “Cannot read property ‘data’ of undefined at Mutation._this.onCompletedMutation” in react-apollo.browser.umd.js:557
  2. Following 2, “Cannot read property ‘queryManager’ of undefined” in offline-link.js:97:31

The mutation and query being composed:

let getEventSchedule = graphql(EventScheduleQuery, {
  options: {
    fetchPolicy: "network-only",
  },
  props: (props) => {
    return {
      eventSchedule: props.data.getEventSchedule,
    }
  }
});
let saveEvent = graphql(SaveEventMutation, {
  props: (props) => ({
    saveEvent: event => {
      props.mutate({
        variables: {
          ...event
        },
        refetchQueries: [{query: getEventSchedule}]
      })
    }
  })
});

It’s been maybe two weeks since I’ve rebuilt the node modules folder but the app was working perfectly with the previous contents. Any ideas?

Some debugging shows that a call to getContext in offline-link.js doesn’t return the client at all, whih explains . number 2, but I don’t know what could be causing that

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
j0b0sapi3ncommented, Jun 27, 2018

I was getting the same offline-link.js error for queryManager being undefined. I fixed it (temporarily) by adding disableOffline: true to the AppSyncClient like so:

      const client = new AWSAppSyncClient({
        url: AppSync.graphqlEndpoint,
        region: AppSync.region,
        auth: {
          type: AppSync.authenticationType,
          jwtToken: this.state.token
        },
        disableOffline: true
      });

I don’t fully understand why, seems like the offline feature should be checking for something, but seems like a bug that should be fixed. I initially got the idea to try it from here: https://stackoverflow.com/questions/48529063/reactjs-apollo-appsync-mutation-optimistic-response-resolved-id

2reactions
kinyatcommented, Jun 27, 2018

This also related to https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/159

https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/79aaaff2444b9772932637ea8c7128c1bdc698a5/packages/aws-appsync/src/client.ts#L204

Since doIt is always false, it didn’t set the client. When do you mutation, it will reach the following code

https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/5897091e3e9c67babee55b9defe7474f8e30a0b6/packages/aws-appsync/src/link/offline-link.ts#L88

Because client is undefined due to doIt is false, it throws Cannot read property 'queryManager' of undefined

I don’t understand how doIt value is being set. Need some helps from AWS team.

Just a fun fact that their example in the other repo also given up with the offline-link

https://github.com/aws-samples/aws-amplify-graphql/blob/master/photo-client/src/App.js#L27

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm rebuild doesn't work when trying to fix different node ...
Solved the issue, I was using an outdated version of node as I was using node v16.13.2 so I tried switching to the...
Read more >
reinstall-node-modules - npm
(re)install node modules only if they have changed. Latest version: 2.0.0, last published: 3 years ago. Start using reinstall-node-modules ...
Read more >
Native Node Modules | Electron
If you installed a native module and found it was not working, you need to check the following things: When in doubt, run...
Read more >
Configuring your application's dependencies - AWS Elastic ...
To avoid needing to create a new environment, change the Node.js version setting in package.json to a Node.js version that is supported by...
Read more >
Cannot find module 'node-sass' on NPM build
There was an outage on Friday 8th at about 1700 GMT, we had an NPM/Angular build in progress. since then our devops builds...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found