graphjin icon indicating copy to clipboard operation
graphjin copied to clipboard

Upsert mutation does not update rows when the array of changes have different fields to update

Open MIRO1990 opened this issue 3 years ago • 0 comments

What version of GraphJin are you using? 0.17.26

Have you tried reproducing the issue with the latest release? Yes

Steps to reproduce the issue.

  • Try upsert mutation on any table
  • In the variables , send an array of changes, where the fields to update are different between the items of the array :

For Example

Query

mutation { books(where: {id: {in : $ids}, upsert: $data){ id author title } }

Variables

{ "ids": ["book_1", "book_2"], "data": [ { "id": "book_1", "author": "New Author 1" }, { "id": "book_2", "title": "New Title 2" } ] }

Note : the second item in the array of changes has different fields to update than the first item in the array of changes

The first item is to update only "author" in book_1, while the second item is to update only "title" in book_2

Expected behaviour and actual result.

Expected behaviour

I expect graphjin to update the rows accordingly [ { "id": "book_1", "author": "New Author 1", "title": "Old Title 1" }, { "id": "book_2", "author": "Old Author 2", "title": "New Title 2" } ]

Actual results

it ignores the second change [ { "id": "book_1", "author": "New Author 1", "title": "Old Title 1" }, { "id": "book_2", "author": "Old Author 2", "title": "Old Title 2" } ]

Now if you include "title" field in the first item in the array even if you don't want to update it, it works

Such as

Variables

{ "ids": ["book_1", "book_2"], "data": [ { "id": "book_1", "author": "New Author 1", "title": "Old Title 1" }, { "id": "book_2", "title": "New Title 2" } ]

then it works and the book_2 is updated with the "New Title 2"

it seems like graphjin takes the first item in the array of changes to be its template for the whole upsert mutation

This is not very helpful, because we don't want to have to include all the fields in the first item in order for the rest of the changes to work.

Is there a fix for that or a way around that?

Thank you !!

MIRO1990 avatar Apr 28 '22 17:04 MIRO1990