Skip to content

page query not working for posts page #2486

@mephysto

Description

@mephysto

Description

As of 1.9.x I can not longer grab certain attibutes of the posts page using the page query

Steps to reproduce

  1. Use WPGraphQL 1.9.x
  2. Set up a page (i.e., "news") to be the posts page in the Reading settings (/wp-admin/options-reading.php)
  3. Edit this page. Add a featured image via the sidebar.
  4. Attempt to retrieve this image using following query:
{
  page(idType: URI, id: "/news/") {
    title
    isPostsPage
    featuredImage {
      node {
        alt: altText
        src: sourceUrl
      }
    }
  }
}
  1. In GraphQL explorer, I would get the following error:
 "errors": [
    {
      "debugMessage": "Argument 1 passed to WPGraphQL\\Type\\InterfaceType\\NodeWithFeaturedImage::WPGraphQL\\Type\\InterfaceType\\{closure}() must be an instance of WPGraphQL\\Model\\Post, instance of WPGraphQL\\Model\\PostType given, called in /nas/content/live/example/wp-content/plugins/wp-graphql/src/Type/WPConnectionType.php on line 447",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "page",
        "featuredImage"
      ]
    }
  ],
  "data": {
    "page": {
      "title": null,
      "isPostsPage": false,
      "featuredImage": null
    }
  },
  1. If I downgrade to WPGraphQL version 1.8.x, I get my intended results:
  "data": {
    "page": {
      "title": "My Cool News Stories",
      "isPostsPage": true,
      "featuredImage": {
        "node": {
          "alt": "aerial-view-of-boat",
          "src": "https://www.example.com/wp-content/uploads/2020/09/aerial-view-of-boat.jpg"
        }
      }
    }
  },

Additional context

No response

WPGraphQL Version

1.9.x

WordPress Version

6.0.1

PHP Version

7.4

Additional enviornment details

Attempted to:

  • disable all other plugins except WPGraphQL, problem persisted.
  • I checked if Image used still existed in Media Library, and not a weird mismatch or missing image

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have disabled ALL plugins except for WPGraphQL.

  • Yes
  • My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionBug that causes a regression to a previously working featuretype: bugIssue that causes incorrect or unexpected behavior

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions