Closed sks444 closed 3 years ago
Having seen this example in isolation, I don't think the content type filter makes sense on the page query. The page query is intendend to return a specific page matching given criteria. content type in isolation is like saying "give me the about page with.." and stopping there. What page? first, last? based on what criteria?
Yeah..that's valid. contentType filter on it's own on a page doesn't make sense.
We just wanted to utilize this filter to get a page which just have one instance. As we can not hard code id
, slug
in frontend as those can be changed. Not sure if there is any other way to get a page with single instance.
I suppose we can use it on pages with limit set to 1.
query {
pages(contentType: "about.AboutPage" limit: 1) {
...on AboutPage {
slug
}
}
}
So this issue should be resolved.
Although I do have one more doubt. Actually we have multi site setup and we are doing these queries under a site. But the support for contentType filter on pages under a site is not yet there. Do you think it would be helpful to have this filter there as well? So we can do something like:
query {
site(hostname: "localhost") {
pages(contentType:"about.AboutPage") {
slug
}
}
}
Hey @sks444 it does make sense to have parity between the global pages search and the site query one, where they make sense.
Are you happy to submit a PR with that?
Sure. Will try to fix this one.
Hi @zerolab, I added a pr for this over at https://github.com/GrappleGQL/wagtail-grapple/pull/171. Let me know your views.
Closing as per https://github.com/GrappleGQL/wagtail-grapple/issues/170#issuecomment-826076611
Query:
Response:
Looks like we can do
page = qs.first()
after this line. So whenever there is only contentType filter passed we return the first page.