Realm Sync: is there anything like Custom Resolvers for GQL API


I have a question regarding Realm Sync.
Here is the use case:
documents stored in Atlas Cluster have some data associated with them in a third-party service and a client should be able to retrieve data from that third-party service along with documents.

In case of GraphQL API this can be solved via a custom resolver with a function that will query the data from third party, so the client will receive all the data in response.
I wounder is there a way to achieve similar behavior in case of Realm Sync?

Hi Ivan, welcome to the forum!

I can see a couple of options for this:

  1. If you want the data to make it to your app via Realm Sync then you need to get that data into an Atlas collection. One way to do that is to configure a scheduled Realm trigger that pulls the data periodically and writes it to your Atlas collection. This approach is nice as the app can access the synced data even when it has gone offline.
  2. Have your app call a Realm function that fetches the external data and combines it with Atlas data before returning with the merged results. This is nice in that you know you will get the very latest data when you run the function; the downside is that the data isn’t accessible when the app is offline.

Thank you for the quick answer!
I was assuming that there are only options you’ve listed, but it’s always better to have an authoritative opinion instead of just assuming.
Likely the first option is the way to go for my use case, as offline access is important.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.