The server extension can be enabled through the plugin configuation. As the resolver and code which creates the schema out of block types registry needs to make additional round trips to gutenberg and back, the wp-graphql-gutenberg tries to be smart enough to analyze the query beforhand and do these requests only if the query actually contains the fields which this plugin exposes or the query is the introspection query of the schema.
The plugin uses its own created WordPress role called 'WpGraphqlGutenberg Server User' and own created user with that role only. The role only has the
edit_posts capability for the custom post type which is used for the Previews feature and which also supports the block editor. Upon each request a short lived cookie is created for this user to access the admin area and the gutenberg is opened with this cookie in the headless browser as if it was opened for new the creation of this post type. This way the blocks api and registry is exposed to the browser and the content can be parsed and sent back to the resolver on the PHP side.
To enable the server extension, you need to define the
WP_GRAPHQL_GUTENBERG_SERVER_URL constant, preferable in your
You can optionaly enable/disable the server with
WP_GRAPHQL_GUTENBERG_ENABLE_SERVER (even if the
WP_GRAPHQL_GUTENBERG_SERVER_URL is defined):