torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!
https://wagtail-grapple.readthedocs.io/en/latest/
Other
153 stars 57 forks source link

urlPath generation with multisite setups. #274

Open dopry opened 1 year ago

dopry commented 1 year ago

In wagtail I have a site, example.com, setup. The root page is Example located at /example. When I query the pages over graphql they all come back with the urlPath /example/path/to/page. I have code in my frontend that parses /example out of the path for every page to generate links. I kind of understand how wagtail's multisite is supposed to work but don't use it. Is there a way to get grapple or wagtail to return a urlPath relative to the site?

seb-b commented 1 year ago

We've also ran into this, it's a bit of a pain to have to filter out home page slugs with next's getStaticPaths. Could a new prop be added to the page interface for a relativeUrlPath? It would return the url path minus the root page slug. Page queries via a urlPath arg already work for relative paths.

A guaranteed relative url would also come in handy for other links in a site, at the moment you only have the option of using the url prop which is absolute or relative depending on the number of sites

dopry commented 1 year ago

@seb-b We started talking about how to fix this in https://github.com/torchbox/wagtail-grapple/issues/306. We would love to have your thoughts there.