Realm Object Server, Custom Backend, and Object Validation


#1

Essentially, I have a Rails backend in front of a Postgres DB. The Rails backend contains all the business logic for model validation, etc.

Of course, I intend to duplicate this logic on the client, but you can’t trust the client. What I would like to do is sync the data to the realm server, and then make an API call to my server and attempt to store the object (Using graphQL or something). If the object is invalid, I would like to return an invalid message to the server, and then (for example) delete the invalid object and propagate the error back to the client.

Is this possible? And is this possible with the Postgres Adapter?

I’ve searched through the docs, but if you could point me in the direction I need to go I would really appreciate it.

Thank you.


#2

@ianward Would you know how to deal with this?


#3

@FreeWorksRob If you want to keep that same business logic you could continue to use the Rails API and then use the global notifier as a REST Client that sends data to your RoR backend. For instance a new object insertion could be translated into a REST POST and pushed to Rails. If the response comes back invalid then you can return the error code back to the client for the user to do something about the error. The error could be return as an error field on the particular object or as a request/response object you can add to your data model - like so:

You would not do this with the Postgres adapter because it does not allow middleware processing before syncing between the two databases.


#4

@ianward can you use the global notifier with cloud? It seems to run on the RoS.


#5

@FreeWorksRob Yes you can use the global notifier with cloud; you just need to host the node application on your own infrastructure.