Query the Homepage

In WordPress, the homepage can be a Page or an archive of posts of the Post post_type (which is represented by WPGraphQL as a “ContentType” node).

This query allows you to query the homepage, and specify what data you want in response if the homepage is a page, or if the homepage is a ContentType node.

{
  nodeByUri(uri: "/") {
    __typename
    ... on ContentType {
      id
      name
    }
    ... on Page {
      id
      title
    }
  }
}

If the homepage were set to a Page, like so:

Then a Page would be returned in the Query Results, like so:

But if the homepage were set to be the Posts page:

Then the results would return a ContentType node, like so: