Solved

Gooddata UI: Get list of available catalog items (based on selected one's)

  • 7 October 2020
  • 1 reply
  • 436 views

In Gooddata analyze page, on selecting an attribute app hides unrelated items (as shared in below screenshot). 

I can see that 2 relatable API calls getting hit after selection -

A. catalog/query: /gdc/internal/projects/<project_id>/catalog/query?c=<token_a>&q=<token_b>

Returning response -

{ "catalogAvailableItems": { "items": [ <item_1_uri>, <item_2_uri>, ... ] } }
 

B. loadDateDataSets: /gdc/internal/projects/<project_id>/loadDateDataSets
{
  "dateDataSetsResponse": {
    "unavailableDateDataSetsCount": 3,
    "dateDataSets": [ <dataset_1_obj>, ... ]
  }
}

In react app using Gooddata UI I already have access to list of all attributes and measures in my code, is there a way I can get list of available items? (based on current selection) like the above catalog/query api.

If not, catalog/query get API uses c and q request parameters. Is there a way I can generate both in my react app?

icon

Best answer by Dan Homola 8 October 2020, 14:31

View original

1 reply

This is unfortunately quite complicated in GoodData.UI <= 7, and Analytical designer orchestrates this logic explicitly.

However, in the new GoodData.UI version (8.0.0), this has been made much simpler and it is supported “first-class”. If migrating to it is feasible for you, please give it a try. After moving to 8.0.0, you can use the catalog module to access the lists of both all items in the workspace (project) and of the items available with regards to the current setup (what you are asking).

You can use it like this

const catalog = await backend.workspace(projectId)
.catalog()
.load();

const allItems = catalog.getItems();

const availableItemsCatalog = await catalog.availableItems()
.forItems([/* your current attributes and measures */])
.load()

const availableItems = availableItemsCatalog.getAvailableItems();
// or
const availableAttributes = availableItemsCatalog.getAvailableAttributes();

 

Reply