Aws-mobile-appsync-sdk-js: aws-appsync is broken in react-native 0.60

Created on 7 Jul 2019  路  13Comments  路  Source: awslabs/aws-mobile-appsync-sdk-js

Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the
official AWS AppSync forum

Do you want to request a feature or report a bug?
bug
What is the current behavior?

undefined is not an object (evaluating '_reactNative.NetInfo.getConnectionInfo')

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.
It is due to improper redux-offline package.
@redux-offline/redux-offline/lib/defaults/detectNetwork.native.legacy.js
var isLegacy = typeof _reactNative.NetInfo.getConnectionInfo === 'undefined';

What is the expected behavior?

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?

Most helpful comment

How to apply this PR until, the owners merge the fix?

All 13 comments

Same. I am getting : Cannot read property 'getConnectionInfo' of undefined

after doing

import AWSAppSyncClient from 'aws-appsync'

redux-offline maintainers working towards a fix on their end

https://github.com/redux-offline/redux-offline/pull/333

Some more on this

My team forked redux-offline and fixed the NetInfo issue, but we still run into problems with aws-appsync-react inside of "lib/rehydrated-rn.js"

During rehydration we get the error: "TypeError: Cannot read property 'isConnected' of undefined"

line 81: react_native_1.NetInfo.isConnected.fetch()

Any news on this ?

Seems like this PR https://github.com/awslabs/aws-mobile-appsync-sdk-js/pull/437 + patching redux-offline are fixing this issue.

How to apply this PR until, the owners merge the fix?

Any update on officially release date of a fix for this issue?

I found a way around it. I forked https://github.com/awslabs/aws-mobile-appsync-sdk-js, then, as this is a mono repo for 2 packages, I created a git repo for each (if someone knows a more elegant solution I'd be happy to hear it), updated dep "@redux-offline/redux-offline": "^2.5.2-native.0", added dep "@react-native-community/netinfo": "^4.1.4" and calls to NetInfo, then in my project I use references to those 2 repos + required ""@react-native-community/netinfo": "^4.1.4"" and linked it :

  "dependencies": {
    "@react-native-community/netinfo": "^4.1.4",
    "aws-appsync": "https://github.com/badaz/aws-appsync#master",
    "aws-appsync-react": "https://github.com/badaz/aws-appsync-react#master",
   [...]

Ideally @redux-offline/redux-offline and react-native-community/netinfo should be peer and dev deps in aws packages

Hi,
We have just released an unstable version that addresses this issue. More details here: https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/443#issuecomment-519310531

Closing this issue as AWS AppSync SDK v2.00 has been released, which supports RN 0.60 and the documentation has been updated as well.

Still getting this error :

Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module @react-native-community/netinfo from node_modules\aws-appsync-react\lib\rehydrated-rn.js: @react-native-community/netinfo could not be found within the project.

OS: windows 10

"dependencies": {
"aws-amplify": "^2.2.2",
"aws-amplify-react-native": "^3.2.0",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"graphql-tag": "^2.10.1",
"react": "16.9.0",
"react-apollo": "^3.1.3",
"react-native": "0.61.5"
},

Still getting this error :

Loading dependency graph, done.
error: bundling failed: Error: Unable to resolve module @react-native-community/netinfo from node_modules\aws-appsync-react\lib\rehydrated-rn.js: @react-native-community/netinfo could not be found within the project.

OS: windows 10

"dependencies": {
"aws-amplify": "^2.2.2",
"aws-amplify-react-native": "^3.2.0",
"aws-appsync": "^3.0.2",
"aws-appsync-react": "^3.0.2",
"graphql-tag": "^2.10.1",
"react": "16.9.0",
"react-apollo": "^3.1.3",
"react-native": "0.61.5"
},

ok, sorry. I had to explicitly install @react-native-community/netinfo . This problem is gone.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manueliglesias picture manueliglesias  路  3Comments

sfegsetsfe picture sfegsetsfe  路  4Comments

asadowns picture asadowns  路  3Comments

AlexThomas90210 picture AlexThomas90210  路  3Comments

yhenni1989 picture yhenni1989  路  3Comments