Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Fix duplicate events and comments #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix duplicate events and comments #16

wants to merge 2 commits into from

Conversation

erezrokah
Copy link

@erezrokah erezrokah commented Apr 13, 2018

Fixes issue #14

Detailed explanation here:
https://stackoverflow.com/questions/49118378/apollo-mutate-calling-update-four-times-for-a-single-mutation

Mutation update event is triggered 4 times instead of 2 for each mutation causing duplication.
This can be handled by setting disableOffline: true (see here https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-react.html#offline-settings)

I've also updated the code that handled duplication since it is only required in NewComment.js and EventComments.js.

I'm not sure if there is a better way of fixing this issue using some kind of AppSync configuration while avoiding disableOffline: true.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

See here as well: awslabs/aws-mobile-appsync-sdk-js#65

@erezrokah erezrokah changed the title Duplicate events and comments fix Fix duplicate events and comments Apr 13, 2018
@@ -36,7 +36,8 @@ const client = new AWSAppSyncClient({
auth: {
type: appSyncConfig.authenticationType,
apiKey: appSyncConfig.apiKey,
}
},
disableOffline: true
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -86,7 +86,10 @@ export default compose(
const query = QueryAllEvents;
const data = proxy.readQuery({ query });

data.listEvents.items = data.listEvents.items.filter(event => event.id !== deleteEvent.id);
const index = data.listEvents.items.findIndex(event => event.id === deleteEvent.id)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant