Discover content with GraphQL

The discover() query provides a way to display learning recommendations by categories and topics. It is commonly used to display as a landing page providing an overview and entry point to browse the content offering. It would support the display of a page looking like this:

null

Here is an example request:

query {
  discover(
    blocks:[
      {type: TopicCarousel, data: L1_TOPICS},
      {type: TopicCarousel, data: TOP_TOPICS},
      {type: LearningCarousel, data:TOP_TOPICS, filters: {topic: "Business Skills"}, names:"Top learning in Business Skills" },
      {type: LearningCarousel, data:TOP_TOPICS, filters: {topic: "Project Management"}, names:"Top learning in Project Management" },
      {type: LearningCarousel, data:USE_FILTERS, filters: {contentGroups:[43003]}, names:"Newest learning in Content Group 43003", sort: {field:CREATED, direction:DESC} },
      {type: LearningCarousel, data:USE_FILTERS, filters: {}, names:"Top-rated Courses", sort: {field:POPULAR, direction:DESC} },
      {type: LearningCarousel, data:USE_FILTERS, filters: {}, names:"Newest Courses", sort: {field:CREATED, direction:DESC} },
    ]
    context: { appId: "someappID", language: "en", region: GLOBAL }
  ) {
   blocks {
      ...on TopicCarousel {
        title
        items {
          id
          parentId
          name
          level
        }
      },
      ...on LearningCarousel {
        title
        metadata {
          name
          topic {
              id
              name
          }
        }
        response(first:5) {
          edges {
            node {
              ... on CourseCard {
                  id
                  title
                  duration
                  image
                  metadata {
                    contentGroups {
                      id
                      title
                      subGroup {
                        id
                      }
                    }
                  }
                }
            }
          }
        }
      }
    }
  }
}

Please make sure to send your OAuth token in the header. Example below:

{
  "Authorization": "Bearer {YOUR OAUTH TOKEN}"
}

Let's examine the query in more detail. Firstly, the discover query expects two arguments:

  • blocks: In here we can define what block we want to display. The combination of type and data allows us to specify the returned information. {type: TopicCarousel, data: L1_TOPICS} for example, returns a carousel with Level 1 Topics, as seen in the screenshot. Available block types and further information can be found below.
  • context: Provides context for the search and is used to improve search results to be more relevant to the individual user.

Available block types:

  • TopicCarousel: Returns data for a Topic Carousel, available data types: TOP_TOPICS and L1_TOPICS
  • LearningCarousel: In here, we can request data for a Learning Item Carousel. Example block definition {type: LearningCarousel, data:USE_FILTERS, filters: {contentGroups:[43003]}, names:"Newest learning in Content Group 43003", sort: {field:CREATED, direction:DESC} } When the data attribute is defined as "USE_FILTERS", all filters of the search() endpoint are available here, as well as the sort options.

Further documentation and the GraphQL API Schema/Reference can be found here.