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

Fix duplicate events and comments#16

Open
erezrokah wants to merge 2 commits into
amazon-archives:masterfrom
Noless:duplicate_events_comments_fix
Open

Fix duplicate events and comments#16
erezrokah wants to merge 2 commits into
amazon-archives:masterfrom
Noless:duplicate_events_comments_fix

Conversation

@erezrokah

@erezrokah erezrokah commented Apr 13, 2018

Copy link
Copy Markdown

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
Comment thread src/App.js
apiKey: appSyncConfig.apiKey,
}
},
disableOffline: true

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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
Copy Markdown
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