I need to create a rest service that delivers the current data:
getNode(nid) -> all node fields -> if field is entity reference (like file, human readable urls) -> include subfields -> if field is type of paragraph, include sub fields again in human readable form
It seems that Drupal is not yet ready for Rest without having to create new requests for every peace of content that is referenced with an id.
For example I have a Pinterest wall kind of output. Each item is created by using a paragraph element (sometimes with other references like taxonomy etc)
I want a clean, json list. Structured correctly without missing nested elements like paragraphs, file or taxonomy references. In this moment I just get the id's of the referenced elements.
Do I have to call now 100+ requests to collect all data for this wall?
1) Or should I make one request for collecting the node:
2) Another request to collect all 1st level entity references. Afterwards to store them in an array.
3) Afterwards making request for 2nd level entity references.
This seems horrible to me when it comes to questions about overhead and time.
Of course I have checked out some modules that should help with this issue:
rest_export_nested module which does not work with paragraphs entity types
rest_views does seem to output the fields as html instead of json. There is no real solution so far.
So what to do? Another way could be to create a view of paragraphs with target id of [NODE_ID]. But this would work just for 1st level paragraphs. The problem would still exist for nested paragraphs.
Is really the only way to create a custom module that creates it's own rest service?
Is the JSON API maybe another solution I haven't looked at so far?
Any input is appreciated. Thanks.