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.

CommentFileSizeAuthor
#2 restws-fields-2555353-2.patch4.44 KBJoeMcGuire

Comments

JoeMcGuire created an issue. See original summary.

JoeMcGuire’s picture

StatusFileSize
new4.44 KB

Patch attached with proposed solution.

The following work:

  1. Not including 'fields' in the querystring will return the full results set.
  2. ?fields=nid,node
    Will return just two fields listed.
  3. ?fields=file
    Will return a full array of all files uploaded to the field (if multiple are allowed).
  4. ?fields=file:5
    Will return only the fifth file if it exists
  5. ?fields=file:5:file
    Will return only the fifth file's 'file' property
  6. ?fields=file:1,file:2,file:3
    Will return first, second and third files.
lokapujya’s picture

Status: Active » Needs review

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