e-Spirit / javascript-content-api-library

Apache License 2.0
7 stars 11 forks source link

fetchNavigation doesn't return all urls #200

Closed LarsOlt closed 6 months ago

LarsOlt commented 6 months ago

We have url paths that are generated from table entries by FS. https://docs.e-spirit.com/odfs/advanced-topics/generation/advanced-urls/index.html

The slug is generated from the title of the blog post.

Example: /blog/[slug] -> /blog/hello-world-post https://www.gruenewoche.de/de/blog/mori-kocht-und-moderiert.html

When using the caas api these routes are missing in the response. Only one slug url from thousands exists. We have already tried changing settings in the FS Site Architect.

image
nico-mcalley commented 6 months ago

Hi Lars! Thank you for reporting the problem.

The content API is using the CaaS and Navigation Service APIs in the background. When the data is incorrect there, it will be wrong when using the content API as well.

Could you verify, the data is correct in Navigation Service? The URL to test this should look similar to this: https://${customer-name}-navigationservice.e-spirit.cloud/navigation/release.${project UUID}?language=de_DE

When it turns out, that the problem is in fact somewhere in between Navigation Service and FirstSpirit, please open a ticket for our customer support. If the data in Navigation Service is correct, we need a reproduction setup for the potential bug.

kind regards Nico

LarsOlt commented 6 months ago

Hi Lars! Thank you for reporting the problem.

The content API is using the CaaS and Navigation Service APIs in the background. When the data is incorrect there, it will be wrong when using the content API as well.

Could you verify, the data is correct in Navigation Service? The URL to test this should look similar to this: https://${customer-name}-navigationservice.e-spirit.cloud/navigation/release.${project UUID}?language=de_DE

When it turns out, that the problem is in fact somewhere in between Navigation Service and FirstSpirit, please open a ticket for our customer support. If the data in Navigation Service is correct, we need a reproduction setup for the potential bug.

kind regards Nico

Same result on the API, we will create a ticket

jodeleit-es commented 6 months ago

Maybe our initial interpretation of your ticket was wrong. Did you read this part of the Navigation Service documentation?

jodeleit-es commented 6 months ago

And this may also help: https://docs.e-spirit.com/module/caas-connect/CaaS_Connect_FSM_Documentation_EN.html#caas-json-format

nico-mcalley commented 6 months ago

When you want to implement an application, that does routing over a FS content projection you could also have a look at our reference PWA implementation. https://github.com/e-Spirit/crownpeak-pwa-template/blob/8870a68877e1df3a25ab936387682ed8420decde/pages/%5B...slug%5D.vue#L52

neo-reply-lukas commented 6 months ago

Generally i would recommend not using NavigationService to resolve routes from ContentProjections, as the RegExp may lead to non deterministic behavior. Instead, fetch routing info from CaaS With a filter equivalent to route = "PATH" or routes.route = "PATH"

That may return either 1 PageRef --> Not a Content Projection 1 Dataset --> Content Projection. PageRef Id in routes.pageRef 1 Dataset & 1 PageRef --> Content Projection. PageRef Id in routes.pageRef is the same that was fetched

From that info, you know the context of your routing and may fetch the correct navigation by Locale and id of the pageRef referenced in the Dataset

LarsOlt commented 6 months ago

Thanks everyone! I built a query using {"route":{"$regex":"/de/blog/*"}} which returns all the matching datasets.

Is it correct behavior that the navigation endpoint only returns one of the dynamic routes? Is it possible to get all the dynamic routes from the navigation endpoint without a custom query?

jodeleit-es commented 6 months ago

Yes, this is expected behavior. The rational behind it that customers may have very many datasets (in the hundreds thousand and even more is not uncommon). These then would be delivered in one big array, because they all "live" in the same folder from FirstSpirit perspective. That's not feasible. With this said I will close the issue.