pristas-peter / wp-graphql-gutenberg

Query gutenberg blocks with wp-graphql
https://wp-graphql-gutenberg.netlify.app
GNU General Public License v3.0
301 stars 62 forks source link

MediaItem query on CoreImageBlock does not work on Page post type #195

Closed brittonwalker closed 1 year ago

brittonwalker commented 1 year ago

The fragment I have for mediaItem on CoreImageBlock that only works for post() query and not page(). It looks like there is no connection for Pages. Results in a 500 error on my frontend Next.js build for an editor trying to use an image block on a Page.

  fragment ImageFragment on CoreImageBlock {
    attributes {
      ... on CoreImageBlockAttributes {
        caption
      }
    }
    mediaItem {
      node {
        altText
        sourceUrl
        sizes
        mediaDetails {
          height
          width
        }
      }
    }
  }

The debug message: WPGraphQL\\Model\\Post::__construct(): Argument #1 ($post) must be of type WP_Post, null given, called in /Users/britton/Development/guild-wordpress/wp-content/themes/guild/functions/register-graphql-fields.php on line 61"

brittonwalker commented 1 year ago

Bad data on my end.