jsonapi-converter icon indicating copy to clipboard operation
jsonapi-converter copied to clipboard

Support for sparse fieldsets and user-defined inclusion of related resources

Open marceloverdijk opened this issue 6 years ago • 6 comments

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.

marceloverdijk avatar Apr 17 '18 21:04 marceloverdijk

@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?

marceloverdijk avatar Apr 26 '18 12:04 marceloverdijk

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 URLparams.

jasminb avatar Apr 27 '18 08:04 jasminb

I will provide an example later (not behind laptop atm). The Fieldsets class should indeed contain some static method to parse a query param.

marceloverdijk avatar Apr 27 '18 08:04 marceloverdijk

@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.

marceloverdijk avatar Apr 30 '18 09:04 marceloverdijk

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.

jasminb avatar Apr 30 '18 14:04 jasminb

Hello @jasminb Any update on that feature? Are there any plans to include it in next releases?

maksym-szymczak avatar Aug 18 '23 13:08 maksym-szymczak