Skip to content

Commit

Permalink
improve datasync spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ssd71 authored and wtrocki committed Jun 20, 2020
1 parent 234b202 commit 6e483bd
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion docs/spec-datasync.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,39 @@ type CommentDeltaList {
Each object of this list is a snapshot of the current state of the row/document in the database, along with the timestamps that show when it was last changed(`updatedAt`), and when it was created(`createdAt`). It also provides info on if the row was deleted(`_deleted`), in which case the `updatedAt` timestamp says when it was deleted.

The objects to be fetched in the delta query can also be filtered by using the `filter` argument
which would work exactly like the filter in the [find](./spec-find.md) query.
which would work exactly like the filter in the [find](./spec-find.md) query.

### Server-side Conflict resolution

If a client goes offline, there is a strong possiblity that the cached data may not be consistent with the data from the source. Thus it is advisable to to have some mechanism for detecting this inconsistency and some way to resolve this. For example, requiring an `updatedAt` timestamp for every mutation is a decent way to ensure this:

```graphql
input MutateCommentInput {
id: ID!
title: String
description: String
updatedAt: String!
}
```

This could possibly detect inconsistencies when issuing mutations and possibly resolve them or inform the client about the differences, for example:

```json
{
"conflictInfo": {
"serverState": {
"id": "5eedae1367d72e2192561723",
"text": "AlreadyUpdatedTitle",
"_deleted": false,
"createdAt": "1592634899084",
"updatedAt": "1592634899084"
},
"clientState": {
"id": "5eedae1367d72e2192561723",
"text": "ClientSideUpdate",
"updatedAt": "1592634898093"
}
}
}
```

0 comments on commit 6e483bd

Please sign in to comment.