RFC: Exclude Certain Models based on settings #1832
moizarafat
started this conversation in
Elide 5
Replies: 1 comment
-
I like Option 1. We can make a bean (Spring), default function (standalone) that returns a named |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We would like to exclude certain models based on some settings. It would mean the models will not be part of JSONAPI, Graphql and Swagger pages/modules.
Expected Behavior
For one of the internal features, if async is not enabled, the AsyncQuery and TableExport models should not be exposed through any of the resources.
Current Behavior
No way to exclude models based on conditions.
Possible Solution
Option 1:
EntityDictionary can take a list of models to be excluded. During the calls for binding the entities from the DataStores, we can check against the list and ignore binding the matching models.
The pros to this approach are that it's not disruptive and no matter what datastore we use the logic will be available.
The cons to this approach are that during bean overriding, users may forget to include any special logic we include for Internal Async models.
Option 2:
Similar to JPA DataStore taking a list of models to bind, the datastores can take a list of models to exclude.
The cons to this option are that all datastores will need to ensure they have logic to handle this. Also during bean overriding, users may forget to include any special logic we include for Internal Async models.
Option 3:
Similar to JPA DataStore taking a list of models to bind, we replicate the same logic to all the supported datastores.
The pros to this approach are that we are extending a feature that we already support for JPA to other data stores.
The cons to this approach are that during bean overriding, users may forget to include any special logic we include for Internal Async models. Any new or custom datastore will have to support this.
Option 4:
Update the Include Annotation to take a condition which would be a method call to ElideSettings.class. For example:
@Include(type = "tableExport", condition ="getAsyncEnabled:<default>")
The
condition
would be a:
separated string with the first element being the method call with return type boolean and the second one will be the default value to use if the method is not found or does not return a boolean value.EntityDictionary.bindEntity() methods will take ElideSettings type object as an argument too. Using reflections, we can call the method on the passed ElideSettings object and use the result of the method to decide on the binding.
The cons to this approach are that DataStore.populateEntityDictionary will have to take an ElideSettings object along with EntityDictionary. It's possible this approach creates a cyclic dependency cos ElideSettings needs DataStore and EntityDictionary but each of those will have methods which take ElideSettings as arguments.
Beta Was this translation helpful? Give feedback.
All reactions