Implement query parameter re-injection for paging operations#3128
Implement query parameter re-injection for paging operations#3128haolingdong-msft with Copilot wants to merge 3 commits into
Conversation
|
Please ignore the pr and do not merge, just trying to assign issue to copilot and do the experiment. See what it will do. |
|
One challenge, is that the query param that need to be re-inject would typically be an optional parameter. Please take this into consideration. |
You're absolutely right about optional parameters. The re-injection logic needs to handle cases where optional query parameters like
For example, the logic should check |
Co-authored-by: weidongxu-microsoft <53292327+weidongxu-microsoft@users.noreply.github.com>
This PR implements query parameter re-injection for paging operations in TypeSpec-generated Java clients, addressing the requirement to preserve certain query parameters across paginated requests.
Problem
Previously, when making paginated requests, query parameters from the original request were not carried forward to subsequent "next page" requests. This caused issues for parameters like
includePendingthat should be preserved across all pages of results.Before this fix:
Solution
This PR implements a complete end-to-end solution:
nextLinkReInjectedParametersSegmentsfrom TCGC and include them in thex-ms-pageableextensionnextLinkReInjectedParameterssupport toXmsPageableandMethodPageDetailsclassesClientMethodTemplateto generate query parameter re-injection logicAfter this fix:
Changes Made
TypeScript Emitter (
code-model-builder.ts)nextLinkReInjectedParametersSegmentsfrom TCGCx-ms-pageableextensionJava Model Classes
XmsPageable: AddednextLinkReInjectedParametersfield with getter/setter methodsMethodPageDetails: AddednextLinkReInjectedParametersfield with getter methodPagingMetadata: Updated to extract and pass re-injected parameters data through the pipelineJava Code Generation (
ClientMethodTemplate)addQueryParameterReInjectionLogic()method that generates null-safe code to re-inject marked query parametersTesting
The implementation includes comprehensive validation:
This solution ensures that query parameters marked for re-injection (like
includePending) are properly preserved across all pages of a paginated request, maintaining consistency with the original request parameters.Fixes #3081.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.