Suggestion: Replicate MongoDB Realm Sync API and use Realm databases.
Building a lite-version of the Dgraph database and keeping it up to date would be hard to maintain IMO. What makes sense to me is to use an existing database, and then build syncing middleware between that database and Dgraph.
Realm is an open-source database that is battle-tested, works in multiple environments (iOS/Swift, Java, Windows etc.) and has built in syncing logic. It’s designed to work with MongoDB Realm Sync which is basically just a middleware API between Realm instances and Mongo Atlas cloud database. You configure your client Realm db like this:
let configuration = AppConfiguration(
baseURL: "https://realm.mongodb.com", // Custom base URL
transport: nil, // Custom RLMNetworkTransportProtocol
localAppName: "My App",
localAppVersion: "3.14.159",
defaultRequestTimeoutMS: 30000
)
let app = App(id: "my-realm-app-id", configuration: configuration)
DigitalOcean have replicated the AWS s3 API and provide the same service with a different pricing model. It works with existing AWS libraries. My thinking is that the solution to the problem could be a middleware API that receives data from Realm db instances by replicated the same endpoints as MongoDB Realm Sync, and then transforms that data into Dgraph transactions.
Then in your mobile client all you need to do is change your config to:
let configuration = AppConfiguration(
baseURL: "https://realm.yourserver.com", // Host the middleware on your server
transport: nil, // Custom RLMNetworkTransportProtocol
localAppName: "My App",
localAppVersion: "3.14.159",
defaultRequestTimeoutMS: 30000
)
let app = App(id: "my-realm-app-id", configuration: configuration)