msgraph-sdk-java
msgraph-sdk-java copied to clipboard
Rename getNextPage to getNextPageRequestBuilder
Expected behavior
// Example
GroupCollectionPage page = graphClient.me().transitiveMemberOfAsGroup().buildRequest().get();
while (page != null) {
groups.addAll(page.getCurrentPage());
page = page.getNextPage();
}
Actual behavior
// Example
GroupCollectionPage page = graphClient.me().transitiveMemberOfAsGroup().buildRequest().get();
while (page != null) {
groups.addAll(page.getCurrentPage());
// Why does getNextPage retuen a request builder????
GroupCollectionRequestBuilder requestBuilder = page.getNextPage();
if (requestBuilder == null) {
break;
}
page = requestBuilder.buildRequest().get();
}
Steps to reproduce the behavior
Just use the sdk :-\
Hi @andjorg Thanks for reaching out. The reason why this method return a request builder and not directly the result response is because you might want to change things on the requests (headers, middleware options...) or use the async method instead (although for that argument, we could technically have two methods, one Async, one sync). We do have an issue logged support for Page iterator, which is supported in the other sdks for other languages. The main reason why we haven't implemented it so far is because we haven't received demand for it. You'd basically query the first page, and then ask the page iterator to go get all the other pages (with ability to interrupt) for you. Can you please have a look at the spec linked in that issue and tell me whether such a feature would solve your scenario?
I would argue that the method name getNextPage is mislading.
Thanks for the additional information. Would getNextPageRequestBuilder make more sense? This would be a breaking change, so it's probably something we'll not change right away.
Hi @andjorg, thanks for your feedback, we really appreciate that. As @baywet pointed out, we are not going to change right away since it's a breaking change. However, this will be considered for the next major release. I will keep this issue open to track the improvement and to let you know when the new version with this enhancement becomes available.
we will not be addressing this issue on the v5 version and the design will change in the V6 version.