After updating our backend with fairly massive category tree we ended up with ~600 components in total in one request and our GET
is basically too big.
I know there is related question:
Request URI too long on spartacus services
and github issue:
https://github.com/SAP/spartacus/issues/6406
but we don't want to use POST
instead of GET
to get the cms components.
Actually, so far we're trying the approach of splitting the big call to the visible part of the navigation and the rest. Spartacus will load nested subnav components in subsequential calls triggered by user action (click, tap). This has additional advantage: kind of lazy loading of the big navigation tree. However the problem is still there during the SSR. We believe no backend changes are required.
I know there are also pagination feature on the backend but not sure how it can be used here (without destroying lots of Spartacus logic for getting the cms components).
Another option we had on the plate was getting the whole menu tree as a JSON
from the backend but this also needs a custom solution on both frontend and backend.
So the question is: are there any other cases of that problem already solved?
I know it's a common problem and one day Spartacus team might provide a solution to it but as for now it would be nice if we have the list of possible solutions so anyone can benefit from it while tackling it's own case caused by the main issue (Spartacus' combining multiple request for cms components into one call, which is good obviously, for most cases :)).
CmsComponentConnector
to replace the one in core lib. InCmsComponentConnector
, there is a functiongetList
. It callsCmsComponentAdapter.findComponentsByIds
, which gets all components in one request. In your customCmsComponentConnector
, you can useOccCmsComponentAdapter.findComponentsByIds
, in which you can pass pagination data (e.g. currentPage, pageSize). - Weizheng Gao