Skip to content

Attach top-level meta in index response #225

Open
@tsterker

Description

@tsterker

It feels like I'm missing something obvious, but I was not able to find a straight-forward way for attaching custom top-level meta to the response (just like the page meta for pagination). I also didn't find any tickets that seemed related to this.

I have different contexts in mind, for which one might want to attach top-level metadata, in case it could inform any design decisions:

  • global - can always be blindly applied globally;
    e.g. requested_at
  • resource-specific - specific metadata/logic for different resources;
    e.g. sortable_fields differs for users and posts
  • query (result)-specific - specific data only available once the query result (in my case a Solr query) is available;
    e.g. facet_fields counts depend on the current query and are only available with the query result

e.g.

{
  "meta": {
      "requested_at": "2018-09-14T00:00:00Z",  // global

      "sortable_fields": ["foo", "bar"],       // resource-specific

      "facet_fields": {                        // query response-specific
          "sizes": {
              "small": 1,
              "medium": 0,
              "large": 3,
          },      
      },
  },
  "links": {
  },
  "data": [
  ]
}

Apologies if there already is a way of achieving this in a clean way. If not, are there any plans of adding support for this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions