Closed Austint30 closed 5 years ago
@Austint30 did you try just initializing the client like this?
const client = new AWSAppSyncClient({
url: AppSyncConfig.graphqlEndpoint,
region: AppSyncConfig.region,
auth: {
type: AppSyncConfig.authenticationType,
apiKey: AppSyncConfig.apiKey,
// jwtToken: async () => token, // Required when you use Cognito UserPools OR OpenID Connect. token object is obtained previously
}
});
and also are you wrapping your app with apollo provider like this
const WithProvider = () => (
<ApolloProvider client={client}>
<Rehydrated>
<App />
</Rehydrated>
</ApolloProvider>
)
export default WithProvider
Let me know how it goes
this happens to me too and this is the client initialization I use:
`export default class App extends Component { render() { return (
);
} }`
@elorzafe I have created a repository here where I was able to reproduce the issue on a small-scale project.
I was seeing this as well. Had to set disableOffline to true on the client.
@jrounsav Thanks for the workaround. Setting disableOffline to true does solve the problem. I was actually already setting disableOffline to true, but I was putting it in the createAppSyncLink instead of the AWSAppSyncClient options.
This works
const client = new AWSAppsyncClient({
disableOffline: true
}, { link });
The docs should mention that appsync does not currently support offline. I spent almost 48 hours trying to figure what I was doing wrong.
Envoyé de mon iPhone
Le 25 sept. 2018 à 17:41, Austint30 notifications@github.com a écrit :
@jrounsav Thanks for the workaround. Setting disableOffline to true does solve the problem. I was actually already setting disableOffline to true, but I was putting it in the createAppSyncLink instead of the AWSAppSyncClient options.
This works
const client = new AWSAppsyncClient({ disableOffline: true }, { link }); — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
The docs should mention that appsync does not currently support offline. I spent almost 48 hours trying to figure what I was doing wrong. Envoyé de mon iPhone
Same with me. I gave up after a couple of days and just temporarily treated all of my mutations as a success until a further solution was found.
I also had this issue, before realising it was due to the offline behaviour.
I found that the mutation's child function was called twice - once with no data, and then again with the response from the server. If I remember correctly, using an optimistic response avoided the issue (the first time the child fn is called, it would be with the optimistic response).
As far as I can tell, this issue is undocumented
I tested the same code with AWS and GraphCool backend. Optimistic update does not help. The first update (from local data) is correct, but then the response from the server seems to void the request and the data turns undefined.
Le jeu. 27 sept. 2018 à 11:23, Jayphen notifications@github.com a écrit :
I also had this issue, before realising it was due to the offline behaviour.
I found that the mutation's child function was called twice - once with no data, and then again with the response from the server. If I remember correctly, using an optimistic response avoided the issue (the first time the child fn is called, it would be with the optimistic response).
As far as I can tell, this issue is undocumented
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/256#issuecomment-425021895, or mute the thread https://github.com/notifications/unsubscribe-auth/AMCgWy-PCv4zRXw8nltQMVb-Xj1eyBuCks5ufJkGgaJpZM4WuwB4 .
@Austint30 thanks for sharing your repo. I will clone it now and see what is going on.
I can confirm that this sample using aws-appsync@1.3.4 has queries, mutation and subscriptions working.
@Jayphen Thanks for your feedback, we will try to clarify that on our documentation.
@philohelp AppSync client supports offline, I just tested this sample app with aws-appsync@1.3.4 and works without issues, do you have a code snippet on how you are configuring and using the client?
@Austint30 I've tested your app code and could reproduced the problem. I will root cause the problem now. Thanks for creating the issue.
@Austint30 @MentalBrake @jrounsav can you try installing aws-appsync@deepdish-next (current version is 1.3.5-link-effect.2)
I've test @Austint30 sample code and has the expected result.
We have fixed this on the latest release (aws-appsync@1.4.0) I will close the issue for now, but feel free to create a new issue if this problem persist.
Hi, I reproduce the problem using Angular 7, "aws-appsync": "^1.7.1", with enableProdMode(). Using disableOffline: true
makes the problem go away. Is it possible the problem is not fixed with Angular 7?
Hi all, same problem here but with queries ("aws-appsync": "^1.7.2") : with disableOffline: true
works like a charm, but when I try enabling offline and making queries with fetchPolicy:"cache-first"
I get a null value returned in the data.queryName object returned from the query, most of the time but not always (sometimes it works). I don't get why the behaviour is different when the cache is hit and does not return value, the behaviour should be the same as having offline disabled right ? Here it seems for som reason that when the cache returns nothing the query does not really try to fetch data from the server.
Any update on this ? Thanks a lot
We have fixed this on the latest release (aws-appsync@1.4.0) I will close the issue for now, but feel free to create a new issue if this problem persist.
Hi @elorzafe , I'm having similar issues but with queries (see my post above). By any chance, do you have news about this ?
Thanks a lot
I was facing this same issue for a while until I found that there was a mismatch between the data I was sending to the server and the graphql input type defined in our AWS AppSync schema!
Our input type had fields that were arrays of strings or arrays of the AWSJSON data type and I was accidentally sending an empty string in one of those fields which caused data creation/persistence to fail and in turn the server was ALWAYS returning null instead of all the fields I expected to get back from the mutation.
I would imagine this could affect both queries and mutations if the data types your input doesn't match EXACTLY what the schema defines and is not an issue with the aws appsync sdk itself.
It's too bad the server doesn't throw any exceptions. I suspect quite a few developers are seeing this behavior which is caused by a data to schema mismatch and an error response from the server would make that issue clear as day. Maybe those errors are being buried somewhere due to our resolvers...
I was facing this same issue for a while until I found that there was a mismatch between the data I was sending to the server and the graphql input type defined in our AWS AppSync schema!
Our input type had fields that were arrays of strings or arrays of the AWSJSON data type and I was accidentally sending an empty string in one of those fields which caused data creation/persistence to fail and in turn the server was ALWAYS returning null instead of all the fields I expected to get back from the mutation.
I would imagine this could affect both queries and mutations if the data types your input doesn't match EXACTLY what the schema defines and is not an issue with the aws appsync sdk itself.
It's too bad the server doesn't throw any exceptions. I suspect quite a few developers are seeing this behavior which is caused by a data to schema mismatch and an error response from the server would make that issue clear as day. Maybe those errors are being buried somewhere due to our resolvers...
Facing the same issue. Update mutation not working. It doesn't throw any errors. What would be the possible cause for this ?
Thank alot
I was just going crazy wondering why my mutation was not invoking! Then finally I saw an error in my console backend.js:6 TypeError: observer.error is not a function
. This lead me to here, and I added disableOffline: true
to my config and my mutation was successfully invoking again.
@elorzafe this still seems to be an issue in 3.0.2 - only way i can get mutations to work is with disableOffline:true
EDIT: I have created a repository here where I was able to reproduce the issue on a small-scale project.
I am trying to use the AWSAppsyncClient in my React web application and I have come across an issue that I have been trying to solve for days to no avail.
I cannot seem to be able to return any data from any of the Mutations I have written. I have tested all of my mutations on the AppSync console and I can confirm all of them do return data and errors. The problem seems to lie within the Client itself (or maybe something is wrong with my setup).
For example, when I call this deleteEntity Mutation I want to display the error message to the screen.
For this, and all similar mutations, no matter what, the data.mutationName returned from the mutation is always null, and error is always undefined even though this mutations do return data on the AppSync console. This even affects the onError callback function that the react-apollo Mutation component offers.
In my Client setup, I have included an error link as per the Apollo docs so I can see the errors in the console.
When any mutation is run, I do get GraphQL errors in the console like so:
It seems that somehow these errors are failing to make it back to the Mutation component.
Here is how I am setting up the AppSync Client:
Dependencies from packages.json