msgraph-sdk-dotnet icon indicating copy to clipboard operation
msgraph-sdk-dotnet copied to clipboard

Performance Limitation in current design | template requests

Open crazygao opened this issue 8 years ago • 3 comments

Hi,

When we use graph as our client library, we often needs to open a list of files. Book1.xlsx, Word1.docx, Book2.xlsx etc.

However, when we generate this query, we often needs to write something like this.

graphClient.Me.Drive.Root.ItemWithPath(Book1.xlsx) graphClient.Me.Drive.Root.ItemWithPath(Word1.docx) graphClient.Me.Drive.Root.ItemWithPath(Book2.xlsx)

Maybe you will ask me to save some variable like graphClient.Me.Drive.Root. and reuse it, but be careful, there are not always only 1 thing I need to replace.

This is quite inefficient because it is actually at least 4 calls before I come to the final request. Request itself is only an url like this.

/me/drive/root/:/Book.xlsx ....

If I make a template like this /me/drive/root/:$1

Every time I call this, it just generate something like template.call(Book1.xlsx) Of course it should also support types you define in your library. This library should allow me to replace this $1 with proper filepath, which is easy standard string interpolation. And I could reuse it. It saves code and performance I think.

Actual behavior

Steps to reproduce the behavior

crazygao avatar Nov 07 '18 08:11 crazygao

@crazygao Thank you for taking the time to provide this feedback. It sounds like an arbitrary request builder object would be helpful here.

I suggest that you fall back to HttpRequestMessage in the meantime. https://github.com/microsoftgraph/msgraph-sdk-dotnet/blob/dev/docs/overview.md#send-http-requests-with-the-net-microsoft-graph-client-library

935900

MIchaelMainer avatar Nov 13 '18 19:11 MIchaelMainer

@crazygao Just to be clear we are on the same page, the following statement only makes 1 HTTP call:

graphClient.Me.Drive.Root.ItemWithPath(Book1.xlsx)

We do not request Me, then request Drive, then request Root. The fluent interface only makes one call for the last object on the statement.

darrelmiller avatar Jan 26 '19 17:01 darrelmiller

You can do this with

var fileName = "Book1.xslx";
var templatedcall = graphClient.Me.Drive.Root;
await templatedcall.ItemWithPath(fileName).GetAsync();

MIchaelMainer avatar May 03 '19 19:05 MIchaelMainer