plugin-graphql icon indicating copy to clipboard operation
plugin-graphql copied to clipboard

Not removed data from store when it deleted in API.

Open uplus opened this issue 5 years ago • 3 comments

Hi! thank you for awesome library!
I found below bug.

When deleted the data in backend, plugin-graphql doesn't remove data from Vuex store on secondary fetch.

Reproduce step

As there is a Item model(GraphQL)

  1. In frontend, Item.fetch({}, true)
  2. In frontend, Item.query().all(). At this time Items count is 5.
  3. In backend, delete one Items randomlly. Items count is 4 in DB.
  4. In frontend, Items.fetch({}, true).
  5. In frontend, Items.query().all(). At this tiem Items count is 5!!. I expect 4 :cold_sweat:

But Vuex-ORM's console log is below. Inserted 4 records.

Vuex-ORM: GraphQL Plugin  Inserting Vuex-ORM: GraphQL Plugin  Inserting
records (4) [{…}, {…}, {…}, {…}]

In vuex store state, state["entities"].items.data has 5 records.

uplus avatar Jun 30 '19 17:06 uplus

This is intended behavior. fetch() doesn't remove anything from the store.

You have to clear your store before doing a fetch when you want this kind of behavior.

Maybe we could add a option to fetch() which automatically detects deleted records and removed them from the store :)

phortx avatar Jun 30 '19 18:06 phortx

I see. I am in favor of this idea.

Maybe we could add a option to fetch() which automatically detects deleted records and removed them from the store :)

uplus avatar Jul 02 '19 12:07 uplus

status about this? I am also having issues on deleted data. what if other user deleted that data, the data in my browser will use that deleted data and so it will cause data issues

shidcordero avatar Jan 27 '21 07:01 shidcordero