/wp-graphql-content-blocks

Plugin that extends WPGraphQL to support querying (Gutenberg) Blocks as data

Primary LanguagePHPGNU General Public License v2.0GPL-2.0

WPGraphQL Content Blocks

End-to-End Tests

WordPress plugin that extends WPGraphQL to support querying (Gutenberg) Blocks as data.

How to Install

This plugin is an extension of wp-graphql, so make sure you have it installed first.

  1. Clone the repo or download the zip file of the project.
  2. Within the plugin folder use composer to install the vendor dependencies:
composer install
  1. Activate the plugin within WordPress plugins page.

How to Use

Once the plugin is installed, you need can perform queries from within the GraphQLi IDE Block data using the contentBlocks field:

{
  posts {
    nodes {
      # contentBlocks field represents array of Block data
      contentBlocks {
        # fields from the interface
        renderedHtml
        __typename
        # expand the Paragraph block attributes
        ... on CoreParagraph {
          attributes {
            content
          }
        }
        # expand a Custom block attributes
        ... on CreateBlockMyFirstBlock {
          attributes {
            title
          }
        }
      }
    }
  }
}