Stream-based pagination for Microsoft Graph API responses.
Follows @odata.nextLink to lazily fetch subsequent pages.
Examples
{:ok, first_page} = GraphApi.Users.list(client: client)
all_users = GraphApi.Pagination.stream(first_page, client: client)
|> Enum.to_list()
Summary
Functions
Collects all items from all pages into a single list.
A convenience wrapper around stream/2 that eagerly fetches all pages.
Extracts page data from a Graph API response.
Returns {items, next_link} where items is the list of items from "value"
and next_link is the URL for the next page (or nil).
Optionally accepts an as: module to cast each item.
@spec stream( map(), keyword() ) :: Enumerable.t()
Creates a lazy Stream that follows @odata.nextLink to yield all items.
Takes the first page response body and options (must include :client).
Optionally accepts :as to cast each item into a schema/view struct.
Examples
{:ok, page} = GraphApi.Users.list(client: client)
stream = GraphApi.Pagination.stream(page, client: client)
all = Enum.to_list(stream)
# With schema casting
stream = GraphApi.Pagination.stream(page, client: client, as: GraphApi.Schema.User)