microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Improved Handling of Unchanged Objects in Graph API .NET SDK

Open
#1,905 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Request: enhancement
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

I would like to propose an enhancement to the Graph API .NET SDK that enables better handling of unchanged objects during patch and post operations. Currently, even if there are no changes in the object being updated, the patch operation is still executed. This feature request aims to provide a mechanism for identifying if an object has updated values and to prevent unnecessary execution of patch and post operations when no changes are present.

Maybe there is already a technique that can be used to accomplish this goal.

Describe the solution you'd like
The suggested solution involves introducing two key features: the ability to identify if an object has updated values and the option to skip patch and post operations when no changes exist in the backing store. By implementing these features, developers can improve the efficiency and reduce unnecessary API calls in scenarios where object updates are conditional based on changes.

var userId = "putYourUserId";
var user = await graphClient.Users[userId].GetAsync();

// Check if the user object has any updated values
bool hasChanges = user.HasChanges();

if (hasChanges)
{
    // Implement the business logic to perform updates on the object

    // Perform the patch operation only if there are changes
    await graphClient.Users[user.Id].PatchAsync(user);
}
else
{
    // No changes, skip the patch operation
    Console.WriteLine("No changes found in the user object. Skipping patch operation.");
}

In the example above, the HasChanges() method is introduced to determine if the object contains any modified properties. This method compares the object's current state with the original values stored in the backing store to identify changes.

With this enhancement, developers gain more control over when to execute patch and post operations, preventing unnecessary API calls and improving performance in scenarios where updates are conditional.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the .NET SDK's backing-store behavior and the PATCH and POST operation paths; the issue names no files or tests. Clarify the intended HasChanges semantics and how unchanged objects should be detected, then define tests showing that changed objects are sent and unchanged objects skip unnecessary calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.