aem-headless-client-js icon indicating copy to clipboard operation
aem-headless-client-js copied to clipboard

Expose RunQuery with QueryBuilder

Open easingthemes opened this issue 9 months ago • 0 comments

runPaginatedQuery can be used with simple config object ({model, fields}). Internally it use queryBuilder and data filter to return only list of results.

This is very useful behaviour for other query types.

Expected Behaviour

Expose runPaginatedQuery functionality for other query types (List, ByPath).

Actual Behaviour

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version

Sample Code that illustrates the problem

Eg: queryByPath using model name and fields object config:

  async fetchByPath(_path) {
    const { query, type } = sdk.buildQuery(modelName, modelFields, {}, { _path });
    const response = await sdk.runQuery(query);
   const { data } = sdk.__filterData(modelName, type, response.data);
  }

It require next sdk methods

  1. buildQuery
  2. runQuery
  3. __filterData

It can be simplified to

const { data } = await sdk.runModelQuery(modelName, modelFields, {}, { _path })

Since this already exist and it's used in runPaginatedQuery.

Logs taken while reproducing problem

easingthemes avatar Sep 21 '23 15:09 easingthemes