EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.

Overview

WPGraphQL Block Editor

This is an experimental plugin to work toward compatiblity between the WordPress Gutenberg Block Editor and WPGraphQL, based on Server Side registration of Gutenberg Blocks.

This stems from this blog post: https://www.wpgraphql.com/2021/03/09/gutenberg-and-decoupled-applications/

And this Github issue: https://github.com/wp-graphql/wp-graphql/issues/1764

Problems

Server Awareness

Gutenberg is a JavaScript application where Blocks are registered in JavaScript and the WordPress server doesn't know what a block is, what attributes a block can have, etc.

Without server awareness of Gutenberg blocks, APIs such as WP-CLI, the WP REST API and WPGraphQL can't expose blocks in a scalable way for decoupled clients to interact with.

Query Blocks as Data

Developers that are working with WordPress in a decoupled context, with WPGraphQL specifically, have expressed a desire to want to query Gutenberg Blocks as data, then use the data in Component-based architectures with Next, Vue, React Native, and similar.

Instead of querying a block of unpredictable markup and parsing it, or querying unpredictable JSON and parsing it, developers want to see what Blocks are available as GraphQL Types, then specify the exact fields they want for their components.

Server Validation

Currently, since blocks are largely client-side only and the server doesn't know about their existence, the server isn't able to validate input from the client before the data is saved.

I don't think we'll be able to solve this for Gutenberg via this plugin, but we might be able to solve it for decoupled clients interested in using GraphQL Mutations to post data back to WordPress and modify blocks.

You might also like...
PHP implementation of JSON schema. Fork of the http://jsonschemaphpv.sourceforge.net/ project

JSON Schema for PHP A PHP Implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Feature

Code shared by the schema packages

Code shared by the schema packages

Like FormRequests, but for validating against a json-schema

JSON Schema Request Laravels Form Request Validation for JSON Schema documents Installation composer require wt-health/laravel-json-schema-request Us

A Symfony bundle that provides #StandWithUkraine banner and has some built-in features to block access to your resource for Russian-speaking users.
A Symfony bundle that provides #StandWithUkraine banner and has some built-in features to block access to your resource for Russian-speaking users.

StandWithUkraineBundle На русском? Смотри README.ru.md This bundle provides a built-in StandWithUkraine banner for your Symfony application and has so

Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.
Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.

API Platform is a next-generation web framework designed to easily create API-first projects without compromising extensibility and flexibility: Desig

GraphQL Bundle for Symfony 2.

Symfony 2 GraphQl Bundle Use Facebook GraphQL with Symfony 2. This library port laravel-graphql. It is based on the PHP implementation here. Installat

Laravel wrapper for Facebook's GraphQL

Laravel GraphQL Use Facebook's GraphQL with Laravel 6.0+. It is based on the PHP port of GraphQL reference implementation. You can find more informati

A framework for serving GraphQL from Laravel
A framework for serving GraphQL from Laravel

Lighthouse A framework for serving GraphQL from Laravel Lighthouse is a GraphQL framework that integrates with your Laravel application. It takes the

GraphQL implementation with power of Laravel

Laravel GraphQL Use Facebook GraphQL with Laravel 5.2 =. It is based on the PHP implementation here. You can find more information about GraphQL in t

Comments
  • Simply fails to load with WP 6.0.2

    Simply fails to load with WP 6.0.2

    With WP 6.0.2 and WPGraphQL, this plugin prevents WPGraphQL IDE from loading within Wordpress.

    Failed to load resource: the server responded with a status of 500 ()
    app.js?ver=029d819e2c38c9f70120:30 Uncaught (in promise) Error: Response not successful: Received status code 500
        at new t (app.js?ver=029d819e2c38c9f70120:30:39347)
        at app.js?ver=029d819e2c38c9f70120:30:78595
        at n (app.js?ver=029d819e2c38c9f70120:30:32923)
        at app.js?ver=029d819e2c38c9f70120:30:32848
        at new Promise (<anonymous>)
        at Object.then (app.js?ver=029d819e2c38c9f70120:30:32814)
        at Object.error (app.js?ver=029d819e2c38c9f70120:30:32933)
        at rh (app.js?ver=029d819e2c38c9f70120:30:7147)
        at ih (app.js?ver=029d819e2c38c9f70120:30:7610)
        at t.error (app.js?ver=029d819e2c38c9f70120:30:8203)
    
    opened by djmtype 0
  • How to get all the blocks of a page/posts without limit?

    How to get all the blocks of a page/posts without limit?

    I am trying to get all the blocks of a page or posts without limit of innerblocks.

    Currenlty we need to do something like this

      id
        blocks {
          name
          innerBlocks {
            name
            innerBlocks {
              name
              innerBlocks {
                name
                innerBlocks {
                  name
                  innerBlocks {
                    name
                  }
                }
              }
            }
          }
        }
    

    I found there is blocksJSON but not able to retrieve any blocks it gave null.

    In plugin it's mentioned like this

    image

    My query

    image

    opened by insaurabh 0
  • Future of project?

    Future of project?

    I guess I'll be the first one to post here. There's much interest on my team for a project like this (we experimented a bit with gatsbywpgutenberg plugin, but it's no longer being maintained.

    My question is - is this a project that's open for PR's? Obviously in the WP world, things change, so this plugin might ultimately not be needed, but in the short term, we'd love to help define some more of the included blocks.

    Feel free to close obviously if this isn't the right place for this discussion.

    Cheers; wp-graphql is a wonderful project!

    opened by murmrs 1
Owner
WPGraphQL
An Open Source WordPress plugin that enables a GraphQL API for WordPress sites
WPGraphQL
Monorepo of the PoP project, including: a server-side component model in PHP, a GraphQL server, a GraphQL API plugin for WordPress, and a website builder

PoP PoP is a monorepo containing several projects. The GraphQL API for WordPress plugin GraphQL API for WordPress is a forward-looking and powerful Gr

Leonardo Losoviz 265 Jan 7, 2023
Syntax to query GraphQL through URL params, which grants a GraphQL API the capability to be cached on the server.

Field Query Syntax to query GraphQL through URL params, which grants a GraphQL API the capability to be cached on the server. Install Via Composer com

PoP 4 Jan 7, 2022
🍞🧑‍🍳 An on-the-fly GraphQL Schema generator from Eloquent models for Laravel.

An on-the-fly GraphQL Schema generator from Eloquent models for Laravel. Installation Quickstart Model schemas Installation This package requires PHP

Scrn 100 Oct 16, 2022
A robust JSON decoder/encoder with support for schema validation.

A robust wrapper for json_encode()/json_decode() that normalizes their behavior across PHP versions, throws meaningful exceptions and supports schema validation by default.

Bernhard Schussek 356 Dec 21, 2022
PHP 8.1 like legacy enum (Experimental Alpha Version)

flux-legacy-enum PHP 8.1 like legacy enum Experimental Alpha Version Installation COPY --from=docker-registry.fluxpublisher.ch/flux-enum/legacy:latest

fluxlabs 1 Dec 12, 2022
This bundle provides tools to build a complete GraphQL server in your Symfony App.

OverblogGraphQLBundle This Symfony bundle provides integration of GraphQL using webonyx/graphql-php and GraphQL Relay. It also supports: batching with

Webedia - Overblog 720 Dec 25, 2022
Pure PHP implementation of GraphQL Server – Symfony Bundle

Symfony GraphQl Bundle This is a bundle based on the pure PHP GraphQL Server implementation This bundle provides you with: Full compatibility with the

null 283 Dec 15, 2022
Test your PHP GraphQL server in style, with Pest!

Pest GraphQL Plugin Test your GraphQL API in style, with Pest! Installation Simply install through Composer! composer require --dev miniaturebase/pest

Minibase 14 Aug 9, 2022
GraPHPinator ⚡ 🌐 ⚡ Easy-to-use & Fast GraphQL server implementation for PHP

Easy-to-use & Fast GraphQL server implementation for modern PHP. Includes features from latest draft, middleware directives and modules with extra functionality.

Infinityloop.dev 34 Dec 14, 2022
The server component of API Platform: hypermedia and GraphQL APIs in minutes

API Platform Core API Platform Core is an easy to use and powerful system to create hypermedia-driven REST and GraphQL APIs. It is a component of the

API Platform 2.2k Dec 27, 2022