View Source Bonfire.API.GraphQL.Pages (bonfire v0.3.5-classic-beta.6)

Link to this section 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.

Link to this section 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()
}

Link to this section 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.