feat: forward request options to Kiota's default handlers - #1089
Open
Egor Sidorenko (esidorenko-sl) wants to merge 2 commits into
Open
Conversation
…s to Kiota handlers GraphClientFactory.CreateDefaultHandlers called KiotaClientFactory.CreateDefaultHandlers() with no arguments, even though Kiota exposes an overload that takes an array of IRequestOption to configure the default handlers (for example a RetryHandlerOption). Because of that, the only way to change retry behaviour was to find the RetryHandler in the returned list, remove it, and add a replacement. This adds a second CreateDefaultHandlers overload that takes an IRequestOption[] and forwards it into KiotaClientFactory.CreateDefaultHandlers, while keeping the existing telemetry handler behaviour. The old overload now just calls the new one with no options, so it keeps working exactly as before and no existing public signature changes. Issue microsoftgraph#1004 asked for this and was closed as by design before the Kiota migration happened, when this option did not exist one layer down yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #1004
Changes proposed in this pull request
CreateDefaultHandlers(GraphClientOptions, IRequestOption[])overload that passes the options through toKiotaClientFactory.CreateDefaultHandlers.CreateDefaultHandlers(GraphClientOptions = null)unchanged, so this is source and binary compatible. It now delegates to the new overload with no options.RetryHandlerOptionreaching theRetryHandlerthat comes back.Kiota's
CreateDefaultHandlersalready takes anIRequestOption[]for configuring the handlers it builds.GraphClientFactorycalls it with no arguments, so those options are dropped before a caller can reach them.Other links
#1004 was closed as by design, and I understand the reasoning: swapping a handler out is a supported approach. I am opening this anyway for two reasons. The overload is additive, so it costs nothing to keep and breaks nothing. And the request in #1004 was to add an optional parameter to the existing method, which would have been a binary breaking change, so it is worth separating the idea from the way it was originally proposed.
If you would still rather not widen the surface here, close it and I will not push back.
Microsoft Reviewers: Open in CodeFlow