Aws-mobile-appsync-sdk-js: Warning: Failed context type: Invalid context `client` of type `AWSAppSyncClient` supplied to `Rehydrated`, expected instance of `AWSAppSyncClient`

Created on 21 Feb 2018  路  7Comments  路  Source: awslabs/aws-mobile-appsync-sdk-js

with new upgrade in packages I get warning

index.js:2178 Warning: Failed context type: Invalid context `client` of type `AWSAppSyncClient` supplied to `Rehydrated`, expected instance of `AWSAppSyncClient`.
    in Rehydrated (at App.js:36)
    in QueryRecyclerProvider (created by ApolloProvider)
    in ApolloProvider (at App.js:35)
    in Router (created by BrowserRouter)
    in BrowserRouter (at App.js:34)
    in WithProvider (created by _class)
    in div (created by _class)
    in _class (at index.js:7)
investigating

Most helpful comment

At some point I was getting the warning (everything works, but you get a scary red warning in the console), but then I nuked my node_modules and yarn.lock/package-lock.json, reinstalled dependencies and it went away

Let me know if that works for you to make the warning go away.

Meanwhile, I'll explore having aws-appsync as a peerDependency of aws-appsync-react instead of a regular dependency

All 7 comments

Just tested this with @dabit3 and we don't get an error when using appsync so it might be coming from amplify. Also the same code works in previous versions!

reference: https://github.com/serverless/serverless-graphql/blob/master/app-client/appsync-client/src/App.js

Hey @sid88in

can you make sure that the versions match
"aws-appsync": "^1.0.11",
"aws-appsync-react": "^1.0.5",

in your yarn.lock/package-lock.json

@manueliglesias yes checked the versions are same as above (I didn't push the yarn to master with new changes). Also, seems like we only get the warning when using amplify with appsync client.

Are you seeing this warning when you use latest packages of amplify and appsync client?

If it helps, I'm getting the same error using this repo: https://github.com/dabit3/appsync-graphql-cities which may be easier to test because it is only AppSync.

I was able to get the error to go away by adding:

options: {
  errorPolicy: 'ignore'
},

I found this temporary solution by reading https://github.com/apollographql/react-apollo/issues/604

At some point I was getting the warning (everything works, but you get a scary red warning in the console), but then I nuked my node_modules and yarn.lock/package-lock.json, reinstalled dependencies and it went away

Let me know if that works for you to make the warning go away.

Meanwhile, I'll explore having aws-appsync as a peerDependency of aws-appsync-react instead of a regular dependency

@manueliglesias thanks! yes everything works for sure, but yeah that red warning is scary indeed ;)

Was this page helpful?
0 / 5 - 0 ratings