e-Spirit / javascript-content-api-library

Apache License 2.0
7 stars 11 forks source link

fetchByFilter field "layout" not working #188

Closed LarsOlt closed 9 months ago

LarsOlt commented 9 months ago

We want to get all entries that use the page template with uid 'language_dependent_label'. In firstspirit these entries are in a folder under global settings. If I look for a single entry by gid using fetchElement, the response contains the field layout: 'language_dependent_label' at the top level.

So to get all entries I use this query.

    const data= await fsxaApi.fetchByFilter({
        filters: [
            {
                field: 'layout',
                operator: ComparisonQueryOperatorEnum.EQUALS,
                value: 'language_dependent_label',
            },
        ],
    });

Using this query gives me an empty response .

{
  page: 1,
  pagesize: 30,
  size: undefined,
  totalPages: undefined,
  items: [
  ],
}

If I directly access the caas api endpoint using the following query params, I get all entries back.

?filter={"template.uid":{"$eq":"language_dependent_label"}}

Environment

"fsxa-api": "10.18.0"

neo-reply-lukas commented 9 months ago

Generally, the filters you write for the fsxa-api need to be matched against the raw CaaS Document, not the mapped format. It's a common mistake and frankly quite counterintuitive... Try your caas query as filter with template.uid and it should work.

Little tip on efficiency: you might want to add an index for the query, if speed matters: https://docs.e-spirit.com/module/caas-platform/CaaS_Platform_Documentation_EN.html#indexes

LarsOlt commented 9 months ago

Thanks, that works. How should we know the raw data structure without checking the undocumented api?

Dramaturco commented 9 months ago

Yes that is not ideal. The problem is that what the data structure looks like is strongly dependent on your FirstSpirit project and templates. There only patterns like pages, sections, rich text and so on.

For now, the best way is to send a request using postman or a similar tool and just have a look at the response.

We are aware of this issue and it will be adressed in a future release.

neo-reply-lukas commented 9 months ago

@LarsOlt As a sidenote: the fsxa-api provides Base Types for CaaS Entries under CaasApi_xxx, e.g. CaasApi_Section They show the general structure of the CaaS Elements, which would have helped in your case. They cannot give you any information about your input components though, so their use is limited