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

Add a getDelta function to GraphRequest

Open markfields opened this issue 3 years ago • 3 comments

Feature Request

Is your feature request related to a problem? Please describe

Working with a /delta endpoint (like me/calendarView/delta in my case) is kind of painful, unless I'm missing something. e.g. here's how I'm extracting the skiptoken:

const skipToken = new URL(response["@odata.nextLink"]).searchParams.get("$skiptoken") ?? undefined;

I have to do the same for deltatoken, then check if either is undefined and then proceed accordingly.

Describe the solution you'd like

See draft PR #408

Describe alternatives you've considered

If the proposed function "doesn't fit" on GraphRequest then I'll just keep it as my own private helper in my code, no worries.

Another approach is to also take a dependency on a vanilla HTTP Client package, set the auth header and call the nextLink/deltaLink directly, but that feels like a bummer.

Additional context

Taking a step back, the point of this whole SDK is to provide an abstraction over simple HTTP requests to the Graph. You can use it instead of a typical HTTP Client, specifying the auth token, other headers, and URL structure through API calls instead of directly on a request object. But then in the case of a /deltas request, the response contains raw URLs to call (@odata.nextLink and @odata.deltaLink). These are unusable in the context of the SDK! So you're left calling those links using a vanilla HTTP Client package (and manually setting the auth token), or awkwardly extracting the skip/delta token to pass to the SDK again.

A much nicer experience as an SDK consumer is to have the SDK take care of those details and present a nice API to encapsulate the semantics of a /delta request.

AB#8733

markfields avatar Mar 25 '21 17:03 markfields

@markfields Thank you for the contribution! I will review the PR and the approaches proposed in this issue and get back to you.

nikithauc avatar Mar 25 '21 22:03 nikithauc

@markfields FYI, the PageIterator task has a getDeltaLink API which gives access to the delta link when working with a collection of items.

The requirement you stated in this issue expects additional capabilities such as a

  1. getDeltaToken()
  2. getSkipToken() while working with paged collection or /delta query. Am I right?

Also, can you please elaborate more on your comment ?

You can use it instead of a typical HTTP Client, specifying the auth token, other headers, and URL structure through API calls instead of directly on a request object. But then in the case of a /deltas request, the response contains raw URLs to call (@odata.nextLink and @odata.deltaLink). These are unusable in the context of the SDK! So you're left calling those links using a vanilla HTTP Client package (and manually setting the auth token), or awkwardly extracting the skip/delta token to pass to the SDK again

Are you suggesting for more capabilities other than the access to deltaToken and the skipToken?

nikithauc avatar Apr 09 '21 07:04 nikithauc

We shouldn't return just the deltatoken or skiptoken. You still have to then build the resource path. We should return deltalink and nextlink without the host + endpoint part of the URL. This way, I can do client.api(deltalink).get().

MIchaelMainer avatar Apr 09 '21 16:04 MIchaelMainer

closing older issue

ddyett avatar Jul 25 '23 05:07 ddyett