plone.restapi icon indicating copy to clipboard operation
plone.restapi copied to clipboard

Show only metadata_fields in GET content

Open razvanMiu opened this issue 2 years ago • 4 comments

There is no way to get only the desired metadatas in GET content

razvanMiu avatar Jun 19 '23 11:06 razvanMiu

My initial reaction is that I would rather avoid adding this complexity unless there is a good reason. Why is it not good enough to only use the data you need from the response?

davisagli avatar Jun 20 '23 14:06 davisagli

One example of usage is that we have blocks that can embed content from other pages and we want to get only some specific metadata. If we get everything the response would be too big, especially if those pages have a lot of blocks. In my case I can avoid getting all the metadata field by making specific endpoints but I thought that making this generic would be useful.

razvanMiu avatar Jun 20 '23 15:06 razvanMiu

Okay, that helps me understand the use case. I'll try to take a look at the PR soon and think about what would be the best way to do it. In terms of performance it would be best to use the summary serializer from catalog metadata so that it isn't necessary to load the full content object from the ZODB. I'm not sure if that belongs in the content GET service, or a new service. (It might be possible to get from the @querystring-search service already, using a path criterion with depth: 1 ... though, that would not handle well when content is moved to a new path... so, a UID criterion then)

davisagli avatar Jun 20 '23 15:06 davisagli

My 0.02€...

  • If a block needs specific fields only, wouldn't it be better to request exact those fields instead of removing some fields?
  • Thinking about caching (Varnish, ...), GET parameters are not a good choice.

jensens avatar Feb 06 '24 11:02 jensens