[CLI]: New command/verb: `delete`
Command Name:
delete
delete command will allow users to remove fields from the config file.
Proposed Usage:
Deleting a relationship
dab delete <<entity_name>> --relationship "<<relationship_name>>"
An entity can have many relationship fields defined in the config file like below.
"relationships": {
"publishers": {
"cardinality": "one",
"target.entity": "Publisher"
},
"reviews": {
"cardinality": "many",
"target.entity": "Review"
},
"authors": {
"cardinality": "many",
"target.entity": "Author",
"linking.object": "book_author_link",
"linking.source.fields": [
"book_id"
],
"linking.target.fields": [
"author_id"
]
}
},
When a relationship name that exists in the config file is specified, then that particular relationship should be removed.
When * is specified as the relationship name, then all the relationships defined for that entity should be removed from the config file.
Deleting a mapping
dab delete <<entity_name>> --mapping "<<column_name>>"
When a valid column_name is specified, the mapping defined for that column should be deleted.
When * is specified, then mappings defined for all the columns should be removed from the config file.
Delete a particular role
dab delete <<entity_name>> --permissions "<<role_name>>"
When a valid role_name is specified, it should be removed from the permissions object. However, if it is the only role present, it should result in an error as it is not possible to have an entity without any permissions defined.
Deleting an entity
dab delete <<entity_name>>
- When an entity that is not present in the config file is specified, it should result in an error.
- It is possible that the entity specified in the config file could have relationships defined on it. There could be other entities in the config file that could have a
relationshipdefined with this specified entity as thetarget.entity. If such a case is identified, then the command should result in an error with a suggestion that these relationships need to be deleted before deleting the entity. - When the entity to delete is not part of any of the relationships defined in other entities, then the entity specified should be removed from the config file.
Deleting all entities
dab delete *
This essentially resets the entire config file. All the entities that were created will be removed. The resulting config will look the same as it was after running only the init command
Need a option for delete mappings section
Let's re-triage and consider for May due to a growing need for this to make a complete local development experience.
@yorek @sajeetharan @Aniruddh25 @seantleonard @abhishekkumams @ayush3797 @aaronburtle
I've triaged and come up with a proposal with regards to how the delete command could look like for removing various fields/sections in the config file.
In the first iteration, I would ideally like to refrain from introducing options for removing very specific items. For instance, removing a database policy for a given action defined under a given role (or) removing an action defined under a given role would not be supported in the first iteration. Options more removing such granular fields such can be added iteratively.
Please kindly take a look and share your thoughts.
Another perspective here, Most GraphQL configuration generation tools do not include a "delete" command in their command-line interfaces (CLI). Adding a "delete" command might lead to complications. However, alternative commands such as "updateWithReplace," "updateWithSet," "updateWithAdd," or "updateWithRemove" can be considered. These commands offer different functionalities for modifying or updating config data without performing direct deletions.
Thanks for the suggestion. When you get a chance, please elaborate with more details and usage examples for each of the commands - updateWithReplace, updateWithSet and updateWithAdd.
Adding more context: In this discussion thread, one of the users had requested a way for removing an incorrectly created relationship.
Less necessary now that we are considering the UI.