View Source Bonfire.API.GraphQL.Pages (bonfire_umbrella v0.9.10-cooperation-beta.62)

Summary

Functions

Returns a Page for the given key, defaulting to an empty one

Returns a post-batch callback (i.e. the third argument to batch/3) for a key which calls get() with the callback param and the key

Create a new pages from a data map, counts map, cursor function and page opts

Create a new Pages from some data rows, count rows and a grouping key. Groups the data by the grouping key on insertion and turns the counts into a map ready for lookup on a per-row basis.

Types

@type counts() :: %{required(term()) => non_neg_integer()}
@type data() :: %{required(term()) => term()}
@type t() :: %Bonfire.API.GraphQL.Pages{
  counts: counts(),
  cursor_fn: (term() -> term()),
  data: data(),
  page_opts: term()
}

Functions

Returns a Page for the given key, defaulting to an empty one

Returns a post-batch callback (i.e. the third argument to batch/3) for a key which calls get() with the callback param and the key

Link to this function

new(data, counts, cursor_fn, page_opts)

View Source

Create a new pages from a data map, counts map, cursor function and page opts

Link to this function

new(data_rows, count_rows, group_fn, cursor_fn, page_opts)

View Source

Create a new Pages from some data rows, count rows and a grouping key. Groups the data by the grouping key on insertion and turns the counts into a map ready for lookup on a per-row basis.

Note: if the grouping key is not present in the returned data rows, this function will crash. Our intuition is that this would mean an error in the calling code, so we would rather raise it early.