aws-mobile-appsync-sdk-js: Network error: Can't find on object (ROOT_QUERY) undefined
Error: Network error: Can't find **graphqlQueryName** on object (ROOT_QUERY) undefined.
It works most of the time but fails about 20% of the time.
Similar to these issues https://github.com/apollographql/react-apollo/issues/1932 https://github.com/apollographql/apollo-client/issues/3311 https://github.com/apollographql/apollo-client/issues/1701
this.hc().then(client => {
return client.query({
query: queryName
fetchPolicy: network-only
});
}).catch(err => {
console.log('appsyncQuery err:', err);
});
this.hc().then(client => {
const observable = client.watchQuery({
query: queryName
fetchPolicy: network-only
});
return observable.result();
}).catch(err => {
console.log('appsyncQuery err:', err);
});
I set up appsync.service similar to this example https://github.com/aws-samples/aws-mobile-appsync-chat-starter-angular/blob/master/src/app/chat-app/appsync.service.ts
private newClient(session) {
return new AWSAppSyncClient({
url: appSyncConfig.graphqlEndpoint,
region: appSyncConfig.region,
auth: {
type: appSyncConfig.authenticationType,
jwtToken: session.idToken.jwtToken
}
}, {
defaultOptions: {
watchQuery: {
fetchPolicy: 'network-only',
}
}
});
}
using “aws-appsync”: “^1.0.15”,
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 6
- Comments: 29 (4 by maintainers)
seeing this issue 100% of the time with AppSync in nodeJS, - https://aws-amplify.github.io/docs/js/api#aws-appsync-sdk.
setting disableOffline to true just makes the program hang.
We are
Same here, key capability for our app. Is there any current activity on this issue?
I’m having the exact same issue as @eightbits-us in Safari Mobile. Setting disableOffline was the only thing that worked for me too.
I doesn’t work even after hydrated. The only time this works for me is if I set the disableOffline option to true
How did you guys solve this issue without disabling offline?
This issue seems to be related to inconsistencies with
state.offline.onlinein redux-offline. The following code from/src/link/offline-link.tssometimes incorrectly reports offline when my application is initially loaded:Unfortunately, waiting for the store to be hydrated does not solve the issue. We will need to disable offline in our application until this bug has been resolved.
@smakman thanks - this fixed it for me as well. However I would like to be able to use the offline capabilities in Safari Mobile, since this was one of the deciding factors in choosing AWS AppSync.
Traced the first issue (of unknown total issues) to be caused by
store.ts, which uses@redux-offline/redux-offline’s default detectNetwork function, which tries to registerwindowsevent (https://github.com/redux-offline/redux-offline/blob/9e84f38be0720a069d47487eb0717b00ada11843/src/defaults/detectNetwork.js) - this causes the link to always use offline strategy (even at initialization)There’s an example in redux-offline’s issue log that shows an example for how the detectNetwork function can be modified for Node.js (or web workers) https://github.com/piranna/redux-offline-Node.js-PoC/blob/master/index.js Most likely need to modify
store.ts’s createStore function that initializes offline with the detectNetwork function described above…I think there are still more of these similar situation needing to be flushed out, but @mikeRChambers610 's solution looks a lot more flexible and promising than patching on this project (thanks for that!). Just leaving the info here for anyone interested in continuing this path 😃
@Jun711 The sample has been archived, are you still looking for a sample with this?
I updated all of the dependencies to the versions least likely to break the build and that seems to have fixed this specific problem: https://github.com/awslabs/aws-mobile-appsync-sdk-js/compare/master...XLNT:master lmk if that works for you as well, @danielbayerlein