(get-context opts)
Gets the :context from a previous invocation of paginate as stored in :before or :after
Gets the :context from a previous invocation of paginate as stored in :before or :after
(paginate
prepared
f
opts
&
{:keys [filter context batch? auto-reset?]
:or {filter (constantly true) context {} batch? false auto-reset? false}})
Paginates the prepared data. Returns a map of {:edges [{:node { ...} :cursor ...} {:node { ...} :cursor ...} ...] :pageInfo {:hasNextPage Boolean :hasPrevPage Boolean :totalCount Integer :startCursor String :endCursor String}}
Required parameters: prepared: The previously prepared data from prepare-paginate.
f: Invoked on each node. Invoked once on all nodes if :batch? is true.
opts: A map that should contain :first or :last, as well as optionally :after or :before.
Optional named parameters: :filter: For a node to be included, this function must return truthy, i.e. any value except nil and false. Defaults to (constantly true).
:context: User-defined data to store in every cursor. Must be pr-str-able. Defaults to {}.
:batch?: Set to true if f should be invoked once on all nodes, and not once for each node. If this is set to true, f must return the output nodes in the same order as the input nodes. Defaults to false.
:auto-reset?: Whether to detect and automatically reset old cursors. Defaults to false.
Paginates the prepared data. Returns a map of {:edges [{:node { ...} :cursor ...} {:node { ...} :cursor ...} ...] :pageInfo {:hasNextPage Boolean :hasPrevPage Boolean :totalCount Integer :startCursor String :endCursor String}} Required parameters: prepared: The previously prepared data from prepare-paginate. f: Invoked on each node. Invoked once on all nodes if :batch? is true. opts: A map that should contain :first or :last, as well as optionally :after or :before. Optional named parameters: :filter: For a node to be included, this function must return truthy, i.e. any value except nil and false. Defaults to (constantly true). :context: User-defined data to store in every cursor. Must be pr-str-able. Defaults to {}. :batch?: Set to true if f should be invoked once on all nodes, and not once for each node. If this is set to true, f must return the output nodes in the same order as the input nodes. Defaults to false. :auto-reset?: Whether to detect and automatically reset old cursors. Defaults to false.
(prepare-paginate {:keys [sort-by version] :as opts} coll)
Prepares data for pagination. Coll should be a set or a vector.
Opts must be a map that contains :sort-by, which should be a vector of keywords that determine the ordering of coll.
Opts may contain a key :version that specifies the version of the running code. This field will be used to detect and reset old cursors. It defaults to a random uuid. You may set it to for example the current git sha.
Prepares data for pagination. Coll should be a set or a vector. Opts must be a map that contains :sort-by, which should be a vector of keywords that determine the ordering of coll. Opts may contain a key :version that specifies the version of the running code. This field will be used to detect and reset old cursors. It defaults to a random uuid. You may set it to for example the current git sha.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close