danivek/json-api-serializer

Support serialization of only meta

ckeboss opened this issue · 2 comments

In the JSON:API spec, for the response from updating a resource:

A server MUST return a 200 OK status code if an update is successful, the client’s current attributes remain up to date, and the server responds only with top-level meta data. In this case the server MUST NOT include a representation of the updated resource(s).

https://jsonapi.org/format/#crud-updating-responses-200

Another when deleting resources https://jsonapi.org/format/#crud-deleting-responses-200

Is there a way currently to not include the data property?

There is currently no way to not include the data property with the current options.

Actually the only possible way I see, is to filter the output data after serialization before returning it to the client.

// Filter data property
const { jsonapi, meta, links } = Serializer.serialize('article', data, context);
return { jsonapi, meta, links };

Added a way to support this, please have a look #92 and let me know what you think.