Closed wtrocki closed 3 years ago
CC @kingsleyzissou
Generally we will need to be able to start replication separately to model setup. So we might have startReplication method on model and this can be triggered from app/components itself.
This is a good point, starting replication automatically might not be desired behaviour in most cases.
@wtrocki
Regarding this, what I'm thinking of doing here is removing the replication config as a parameter to the setup model method here:
Then we can add another function called applyReplicationFilters
where we can add filters to our replication config in React context and then init the datastore once that has been set. If no filters have been applied, we could use the default config at that point.
Do you see any downsides to this approach?
How and when are we going to start replication? Would this mean that if someone doesn't add filter things will never replicate?
The idea would be to start replication in context, but start it later. If a filter isn't provided, we can revert to the default config. Alternatively, we could keep it as is and use the context to update the filters for the replication config for each model.
Sounds like plan
Okay after initial investigation, we will have to do a startReplication method on the server. I will drop a work in progress PR sometime today.
I need to defer the building of the graphql schemas until after we've applied the filter, but I will put some comments on the code to highlight this.
Feature Request
The query for datastore might not be known at the moment of creating the store. For example, logged user ID needs to be retrieved etc.