jsonapi-converter
jsonapi-converter copied to clipboard
Support for sparse fieldsets and user-defined inclusion of related resources
As per the jsonapi spec how to handle sparse fieldsets and user-defined inclusion of related resources is documented.
Would you consider adding these to jsonapi-converter? If you are interested we can discuss this first or I can make a PR.
@jasminb I was thinking of introducing dedicated Fieldsets
and Includes
objects that can be passed to overloaded writeDocument
and writeDocumentCollection
methods like:
writeDocument(JSONAPIDocument<?> document, Fieldsets fieldsets)
writeDocument(JSONAPIDocument<?> document, Fieldsets fieldsets, Includes includes)
writeDocument(JSONAPIDocument<?> document, Includes includes)
In getDataNode
we can use there arguments to remove fields from the json output.
Would you like that approach?
Hey @marceloverdijk, let me think on this a bit. At first thought it looks simple enough. Im bit concerned about how one would build Fieldsets
for cases where there is some heavy nesting going on.
On the other hand, it could be really useful when using the lib server side to simply be able to create Fieldset
object from URL
params.
I will provide an example later (not behind laptop atm).
The Fieldsets
class should indeed contain some static method to parse a query param.
@jasminb Could you maybe have a look at https://github.com/marceloverdijk/jsonapi-converter/commit/abaa618c0f86157425d0d746a887a6e5030869d6 ? This provides functionality for sparse fieldsets and user-defined inclusion of related resources as per the JSON:API spec. I still need to write tests for it, but feedback would be welcome already.
Will take a look as soon as I can, will update you when I do.
Get Outlook for iOShttps://aka.ms/o0ukef
On Mon, Apr 30, 2018 at 11:15 AM +0200, "Marcel Overdijk" <[email protected]mailto:[email protected]> wrote:
@jasminbhttps://github.com/jasminb Could you maybe have a look at marceloverdijk/jsonapi-converter@abaa618https://github.com/marceloverdijk/jsonapi-converter/commit/abaa618c0f86157425d0d746a887a6e5030869d6 ? This provides functionality for sparse fieldsets and user-defined inclusion of related resources as per the JSON:API spec. I still need to write tests for it, but feedback would be welcome already.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/jasminb/jsonapi-converter/issues/185#issuecomment-385347651, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AC5vp-qAlVfmLveGJBNGj3by3y6-0edaks5tttY4gaJpZM4TZEaT.
Hello @jasminb Any update on that feature? Are there any plans to include it in next releases?