ra-data-prisma icon indicating copy to clipboard operation
ra-data-prisma copied to clipboard

Idea: rework resource dependent options

Open macrozone opened this issue 1 year ago • 3 comments

options grew organically and currenlty contain (among others):

  • ResourceViews, which was initially to create "virtual" resource, but can now be used to customize fragment for one and many queries
  • customizeInputData, can be used to alter input data before beeing sent to the backend
  • filters, can be used to create custom filters. They are currently global, and not dependent on resources, which is odd

all those options kindof are related to a specific resource, so we could consider to rework those into something like this:


type Options = {

  resources: ResourceOptions

...

}


type ResourceOptions = Record<string, ResourceOption> // whereas key is the resourceName

type ResourceOption = {
   backendResource?: string // defaults to the key. This can be altered for "virtual" resources
  fragments: { // to alter what data is fetched, 
     one: ...,
     many: ... 
  },
  customizeInputData: {
     create: ...,
     update: ...
  },
filters: ...
}

so basically group the options. That will make it a bit easier to think about further improvements and customizations and is more logical

macrozone avatar Mar 23 '23 16:03 macrozone