Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strapi v5: A way of fetching all navigations with GraphQL #460

Open
michsko544 opened this issue Oct 17, 2024 · 3 comments
Open

Strapi v5: A way of fetching all navigations with GraphQL #460

michsko544 opened this issue Oct 17, 2024 · 3 comments
Assignees
Labels
feature request Community feature request v5 Strapi v5

Comments

@michsko544
Copy link

I would like to ask if it is currently possible to fetch all navigations at once using GraphQL?

If not, I would like to request this feature, as it would be very useful in my use case.

Use Case: In my page layout, I need to fetch multiple menus, such as the main navigation menu and the footer menus. Instead of fetching each menu individually, I would prefer to fetch all menus in a single GraphQL query and then utilize them in the appropriate sections by using their slugs.

This would simplify the data-fetching process and improve efficiency.

Thank you for considering this request!

@cyp3rius
Copy link
Contributor

GQL does not support it yet.

Would you like to fetch all with nested items ? Or just flat structure to preprocess on the FE?

@michsko544
Copy link
Author

It would be great to handle both cases, e.g. via the type parameter. In my case, I use a flat structure for the mobile version and a tree structure for the desktop version

If I had to choose one, I would prefer to receive an API response with nested elements.

@cyp3rius cyp3rius self-assigned this Oct 17, 2024
@cyp3rius cyp3rius added feature request Community feature request beta v5 Strapi v5 and removed beta labels Oct 17, 2024
@liqueflies
Copy link

liqueflies commented Dec 3, 2024

@michsko544

in graphql you can do that natively, maybe this can fit to you

#import ./fragments/NavigationItem.gql

query GetNavigation($locale: I18NLocaleCode) {
  footer: renderNavigation(locale: $locale, navigationIdOrSlug: "footer-navigation", type: TREE) {
    ...NavigationItem
  }
  navigation: renderNavigation(locale: $locale, navigationIdOrSlug: "main-navigation", type: TREE) {
    ...NavigationItem
  }
  mobile: renderNavigation(locale: $locale, navigationIdOrSlug: "mobile-navigation", type: TREE) {
    ...NavigationItem
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Community feature request v5 Strapi v5
Projects
None yet
Development

No branches or pull requests

3 participants