Graphback: [DataSync] Conflicts occur even when different fields are changed on server and client

Created on 13 Aug 2020  路  4Comments  路  Source: aerogear/graphback

Tried updating two different fields and it still conflicts, because the different ObjectId's are being compared in these places:
https://github.com/aerogear/graphback/blob/98826cc129901da4b8c88c9798ebdfce9f90db78/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L135
https://github.com/aerogear/graphback/blob/98826cc129901da4b8c88c9798ebdfce9f90db78/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L140
On debugging:

> base._id === serverData._id
false
> base._id.toString() === serverData._id.toString()
true
bug datasync

Most helpful comment

@craicoverflow Really sorry for giving so little context!
I think just adding it to the ignoredKeys would do the job. This would be correct because both base and serverData are fetched according to the _id sent by the client, and are guaranteed to have the same _id so there is no need to compare these in the first place. Quick fix, I'll push this in some time.
https://github.com/aerogear/graphback/blob/98826cc129901da4b8c88c9798ebdfce9f90db78/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L124
https://github.com/aerogear/graphback/blob/98826cc129901da4b8c88c9798ebdfce9f90db78/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L132-L144

All 4 comments

Automatically generated comment to notify maintainers
/cc @craicoverflow, @machi1990, @wtrocki

Is this in the MongoDB provider? At runtime can you know if it is an ObjectID?

Would ObjectId.equals work? https://mongodb.github.io/node-mongodb-native/api-bson-generated/objectid.html

@craicoverflow Really sorry for giving so little context!
I think just adding it to the ignoredKeys would do the job. This would be correct because both base and serverData are fetched according to the _id sent by the client, and are guaranteed to have the same _id so there is no need to compare these in the first place. Quick fix, I'll push this in some time.
https://github.com/aerogear/graphback/blob/98826cc129901da4b8c88c9798ebdfce9f90db78/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L124
https://github.com/aerogear/graphback/blob/98826cc129901da4b8c88c9798ebdfce9f90db78/packages/graphback-datasync/src/providers/DataSyncConflictProvider.ts#L132-L144

Looks like it can be closed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

b1zzu picture b1zzu  路  7Comments

lastmjs picture lastmjs  路  4Comments

lastmjs picture lastmjs  路  7Comments

machi1990 picture machi1990  路  3Comments

ankitjena picture ankitjena  路  5Comments