iTwin / imodels-clients

Monorepo for iModels API clients
MIT License
6 stars 1 forks source link

GetChangesetListUrlParams `$top` is being ignored #247

Open EK723 opened 1 month ago

EK723 commented 1 month ago

The urlParams $top (located at GetChangesetListParams > GetChangesetListUrlParams > CollectionRequestParams) is being ignored when running, for example,ChangesetOperations.getMinimalList(). If $top is set to 1, rather than returning 1 item, the program returns the entire list of changesets.

austeja-bentley commented 1 month ago

Hello, the $top parameter is put directly into the url when sending requests to iModels API and it specifies the page size in which entities are retrieved. All collection query functions in IModelsClient return iterators, which, when iterated in full, will return all entities regardless of the page size it uses to query all entities. If you want to query just one entity, abort the iteration early with take helper function:

const getChangesetListParams: GetChangesetListParams = {
  authorization,
  iModelId: testIModel.id,
  urlParams: {
    $top: 1
  }
};

const changesetsIterator: EntityListIterator<Changeset> = iModelsClient.changesets.getRepresentationList(getChangesetListParams);
const changesets: Changeset[] = await take(changesetsIterator, 1);
const changeset = changesets[0];