recommendations

Fetching popular content

Display your trending content items. Check out the Recommendations guide for a quick introduction.

The GraphQL API creates a corresponding GraphQL Type with a "Popularity" algorithm for each content model in your environment. The plural Type name of the content model is prefixed with Popular_. For example Post generates a Type Popular_Posts.

{
  Popular_Posts(
    events : [Bookmark, View]) {
    items {
        _id,
        title
    }
  }
}

Adding the events argument is optional, by default Prepr uses all events to calculate popularity.

Check the Capture Documentation on how to get started with events.

To narrow down the recommended content items, use the same filters that are available when filtering collections.

In the following example, we query all Posts where premium is set to true.

{
  Popular_Posts(
    where : { premium : true } ) {
    items {
        _id
    }
  }
}