We’re trying to run a query on Realm’s flexible sync configuration for a Realm model that has embedded references to other models on Flutter SDK.
There are two challenges we are facing:
Immediate Result Set returned from the query (given no data is present on local) is
empty and only works after the app is relaunched when realm sync adds the data to
local.
References to other Realm Objects that are not queried but are embedded in the
queried object are null by default and there is no way to retrieve them (as not even the
ObjectIds are returned)
This will resolve when the requested data has been downloaded locally. If you don’t include it, the data will still download in the background, you just won’t be notified when the download is complete.
For the second question, there are two problems. First one is that the objects Profile links to are not embedded - note how embedded relationships are declared in json schema. Instead, they’re linking to objects in other collections, which will not be downloaded at this point. We are currently working on a project that will allow you to specify which links you want to include (e.g. mutableSubscriptions.add<Profile>(profileQuery).include("address")) but that’s not ready yet and we don’t have a definitive timeline for when it’ll ship.
Now, the obvious fix would be to switch those relationships to be embedded ones, in which case you’ll receive all the objects along with the original query - the problem is that the flutter SDK doesn’t support embedded objects yet. We have a PR that adds support and we hope to ship it in the near future, but again, don’t have a definitive timeline for when that’ll happen.