Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
33.56k stars 1.87k forks source link

fix(Sync): Do not show conflicts for empty keys #7556

Closed gatzjames closed 1 week ago

gatzjames commented 1 week ago

Highlights:

Problem:

e.g. Previous version of object:

{
   "id": "1",
}

New version of object:

{
  "id": "1",
  "newProp": undefined
}

This should not show up in changes that need to be commited.

Approaches Tested:

Comparison between the two approaches:

VCS (Compare against previous version) DB (only update keys that are optional if they have a value) Models (New keys should be optional and default to undefined)
Doesn't rely on undefined values on the initial model Relies on undefined values on the initial model Relies on new keys defaulting to undefined
Works for any kind of diff that happens between two versions of an object. If the previous version doesn't contain a key and the new version has an empty value* there will not be any changes Only works for keys that are specified as undefined in the initial model and only for when we call the database.update method. Works for all objects
Requires getting the previous version of the document using a specific method for VCS (different between Insomnia Sync and Git Sync) Works with all types of VCS since it only relies on DB models Works for all types of VCS
TBD how this works with a previous version of the app pulling and pushing changes TBD how this works with a previous version of the app pulling and pushing changes ✅ Tested with previous versions

✅ After discussion with the team we decided to go with the last approach: Models (new keys should be optional and default to undefined)