I’m using the graph api from a c# app to access SharePoint. I need to get a list of all folders and sub folders. I have tried getting the drive item and then iterating through the children looking for folders and then recursively working through the list but it’s too slow.
I have also tried this end point
With this header Prefer: HonorNonIndexedQueriesWarningMayFailRandomly
But it returned that the query would consume too many resources.
Is there a way to A. Get the folders more efficiently or B. Do a search to return folders or C. Only list folders in the children endpoint