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: "/") {
    ... on ContentType {
    ... on Page {

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:

Published by Jason Bahl

Jason is a Principal Software Engineer at WP Engine based in Denver, CO where he maintains WPGraphQL. When he's not writing code or evangelizing about GraphQL to the world, he enjoys escaping from escape rooms, playing soccer, board games and Fortnite.