robertl357's avatar
robertl357
Copper Contributor
Jan 26, 2024
Status:
New

Graph API $select nested properties

It would be nice if the Graph API could allow developers to specify $select parameters for nested properties. Currently the $select parameters only work for "top-level" properties, but if they worked with nested properties as well, it could further help to limit the amount of data returned and reduce the size of the JSON response. Some of the nested properties can be rather large like the driveItem 'parentReference' property. This is an 'itemReference' resource type and if it is $select 'ed, you end up having to get everything, even if you only cared about retrieving the 'id'.
Something like the following would be ideal:
 
GET /drive/{drive-ID}/items/{item-ID}?$select=id,name,parentReference:id
 
And get back something like this:
 

 

 

 

{
    "id": "023KLJSDG0235823592D",
    "name": "some_file.txt",
    "parentReference": {
          "id": "4964346HDHHGSDG2423423K"
    }
}

 

 

 

Instead of having to do this:

GET /drive/{drive-ID}/items/{item-ID}?$select=id,name,parentReference

 

And getting back something like this:

 

 

{
   "id": "023KLJSDG0235823592D",
   "name": "some_file.txt",
   "parentReference": {
      "driveType": "documentLibrary",
      "driveId": "b!332KNJN2K3689MNJN234NUNk",
      "id": "045DFHDHFJFDMF258JDJN",
      "name": "some_folder",
      "path": "/drives/b!332KNJN2K3689MNJN234NUNk/root:/some_folder",
      "siteId": "2bh566-1234-56k-235kioih-58w53jkdjj"
   }
}

 

 

 

  • WillDrotar's avatar
    WillDrotar
    Copper Contributor

    Works for me using expand + select

     

    /drive/{drive-ID}/items/{item-ID}?$select=id,name&$expand=parentReference($select=id)