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

contentType filter on a Page doesn't work #170

Closed
sks444 opened this issue Apr 24, 2021 · 7 comments
Closed

contentType filter on a Page doesn't work #170

sks444 opened this issue Apr 24, 2021 · 7 comments

Comments

@sks444
Copy link

sks444 commented Apr 24, 2021

Query:

query {
  pageByID: page(id: 5) {
    contentType
  },
  pageByContentType: page(contentType: "about.AboutPage") {
    id
  }
}

Response:

{
  "data": {
    "pageByID": {
      "contentType": "about.AboutPage"
    },
    "pageByContentType": null
  }
}

Looks like we can do page = qs.first() after this line. So whenever there is only contentType filter passed we return the first page.

@zerolab
Copy link
Member

zerolab commented Apr 24, 2021

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?

@sks444
Copy link
Author

sks444 commented Apr 24, 2021

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.

@sks444
Copy link
Author

sks444 commented Apr 24, 2021

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
    }
  }
}

@zerolab
Copy link
Member

zerolab commented Apr 24, 2021

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?

@sks444
Copy link
Author

sks444 commented Apr 24, 2021

Sure. Will try to fix this one.

@sks444
Copy link
Author

sks444 commented Apr 24, 2021

Hi @zerolab, I added a pr for this over at #171. Let me know your views.

@zerolab
Copy link
Member

zerolab commented Apr 25, 2021

Closing as per #170 (comment)
#171 fixes the use case outlined in #170 (comment)

@zerolab zerolab closed this as completed Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants