-
Notifications
You must be signed in to change notification settings - Fork 62
DeltaResponseHandler adds a delta response payload manifest to CollectionPage.AdditionalData #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
modified: src/Microsoft.Graph.Core/Extensions/BaseRequestExtensions.cs Added WithResponseHandler<T> modified: src/Microsoft.Graph.Core/Requests/BaseRequest.cs Added property to make the response handler accessible. new file: src/Microsoft.Graph.Core/Requests/DeltaResponseHandler.cs Added DeltaResponseHandler to capture changed property names and add them to a list that is added to a prpoerty named 'changes'. modified: src/Microsoft.Graph.Core/Requests/IBaseRequest.cs Added ResponseHandler property. new file: src/Microsoft.Graph.Core/Requests/IResponseHandler.cs Added a common interface for creating response handlers. modified: src/Microsoft.Graph.Core/Requests/ResponseHandler.cs Now implements the common interface. modified: tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/ResponseHandlerTests.cs
tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/ResponseHandlerTests.cs
Outdated
Show resolved
Hide resolved
|
As suggested, I agree it would be a better experience to provide a way to return an instance of I think this may also make it easier for the user to correlate the |
| /// deserializer can't express changes to null so you can now discover if a property | ||
| /// has been set to null. This is intended for use with a Delta query scenario. | ||
| /// </summary> | ||
| public class DeltaResponseHandler : IResponseHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docs on how to use this. Ideally, this is only used after an initial sync, as we have to inspect the contents of the response twice to determine the change list.
|
@andtu for future review |
tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/ResponseHandlerTests.cs
Outdated
Show resolved
Hide resolved
tests/Microsoft.Graph.DotnetCore.Core.Test/Requests/ResponseHandlerTests.cs
Show resolved
Hide resolved
andrueastman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works as described in the description. 👍
andrueastman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Delta query provides a way to track changes. You begin to track changes with a request like this:
GET https://graph.microsoft.com/v1.0/users/delta?$select=displayName,givenName,surnamevar userDeltaCollectionPage = await graphClient.Users.Delta().Request().Select("displayName,givenName,surname").GetAsync();Currently, a developer has to inspect the selected properties on each object in the page. The inspection requires first that they check that the selected properties are not null before getting the changed value. If the selected property is a primitive, then they can capture that value. If the selected property is an object, they must also inspect all of its property with a null check before capturing the values. This may mean unnecessarily checking many properties that have not changed. This PR should reduce the amount of null checking that has to occur when a delta query payload is received by providing a manifest of changes. This is especially useful when a property has been set to null as previously, there was no way to determine whether a property has been set to null, or was not set and so it defaulted to null.
The change manifest is set on each item in the CollectionPage. It is found in the AdditionalData dictionary with a a key called
changes. This functionality is accessed via:Microsoft.Graph.Core
Microsoft.Graph
This enables developers to discover values set to null when using the service library.
The raw JSON on the object after adding the change list looks like:
{ "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(event)", "@odata.nextLink": "https://graph.microsoft.com/v1.0/me/calendarView/delta?$skiptoken=R0usmci39OQxqJrxK4", "value": [ { "@odata.type": "#microsoft.graph.event", "@odata.etag": "EZ9r3czxY0m2jz8c45czkwAAFXcvIw==", "subject": null, "id": "AAMkADVxTAAA=", "changes" : ["@odata.type", "@odata.etag", "subject", "id"] } ] }This also now allows developers to add their own response handler to any request builder. This enables new ways to process the contents of a request builder based response.
Generally, a change results in the returning the entire item with the original property set.
https://docs.microsoft.com/en-us/graph/api/driveitem-delta?view=graph-rest-1.0&tabs=http