msgraph-sdk-java icon indicating copy to clipboard operation
msgraph-sdk-java copied to clipboard

Rename getNextPage to getNextPageRequestBuilder

Open andjorg opened this issue 2 years ago • 4 comments

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 :-\

andjorg avatar Oct 01 '21 07:10 andjorg

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?

baywet avatar Oct 01 '21 11:10 baywet

I would argue that the method name getNextPage is mislading.

andjorg avatar Oct 04 '21 11:10 andjorg

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.

baywet avatar Oct 04 '21 11:10 baywet

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.

maisarissi avatar Nov 11 '21 16:11 maisarissi

we will not be addressing this issue on the v5 version and the design will change in the V6 version.

ddyett avatar Jul 06 '23 16:07 ddyett