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

Add breadcrumb information to GraphQL queries #335

Open
denisyilmaz opened this issue Dec 13, 2022 · 1 comment
Open

Add breadcrumb information to GraphQL queries #335

denisyilmaz opened this issue Dec 13, 2022 · 1 comment

Comments

@denisyilmaz
Copy link

What are you trying to do?

To render breadcrumbs for a given entry it would be great to be able to query for the breadcrumbs.

What's your proposed solution?

Something like this:

{
  entry(id: 123) {
    breadcrumbs {
      title
      url
      segment
      elementId
      elementType
    }
  }
  breadcrumbs(id: 123) {
    title
    url
    segment
    elementId
    elementType
  }
}

Additional context

No response

@engram-design
Copy link
Member

Two things of note - firstly nesting it within the entry interface might be tricky without creating a custom field that is owned by an entry. But it might be possible with a directive.

Secondly, determining the breadcrumbs of an entry really relies on the current URLs segments, which isn't going to be possible in a GraphQL query context (or headless in general). The current implementation will look at each segment in a URL, and if a segment matches the URI of an element, that's used, if not the segment (as a URL) is used.

I can see you're passing in an id param to represent the "current" entry/element for that purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants