Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marceloverdijk opened this issue Apr 17, 2018 · 6 comments

Comments

@marceloverdijk
Copy link
Contributor

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
Copy link
Contributor Author

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

@jasminb
Copy link
Owner

jasminb commented Apr 27, 2018

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.

@marceloverdijk
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@jasminb
Copy link
Owner

jasminb commented Apr 30, 2018 via email

@maksym-szymczak
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants