Currently you can either receive the full entity or just the ID's in a response depending if you set the full parameter.
It would be great to have a more granular API to define the fields you would like returned. So I propose:
?fields=title,nid,gallery:0:file
In the above syntax only the title,nid and galleries first file would be returned.
This is great for both reducing the load on the server as restws currently loops around every field which needs to be loaded and also does permission checking. It is also a win by reducing the quantity of data to transfer.
Comments
Comment #2
JoeMcGuire commentedPatch attached with proposed solution.
The following work:
?fields=nid,nodeWill return just two fields listed.
?fields=fileWill return a full array of all files uploaded to the field (if multiple are allowed).
?fields=file:5Will return only the fifth file if it exists
?fields=file:5:fileWill return only the fifth file's 'file' property
?fields=file:1,file:2,file:3Will return first, second and third files.
Comment #3
lokapujyaThere is a patch so setting to Needs Review. I've noticed some other rest API's support a field Query Language. Another way this could possibly be achieved (with Drupal 8) is using rest in combination with Views.