vip-go-nextjs-skeleton icon indicating copy to clipboard operation
vip-go-nextjs-skeleton copied to clipboard

Utilize wp-graphql-content-blocks instead of custom Blocks plugin

Open abid-din-akqa opened this issue 1 year ago • 4 comments

I found that when utilizing the out of the box setup, the data returned from blocks wasn't the most ideal when working with React.

  1. Ideal to have block data exist under "attributes"?
  2. The block data was returned as a string via the included plugin.

Instead, we went with wp-graphql-content-blocks which returns the data in a way which is much easier to work with.

In conjunction, this also allows the ability to get block data from ACF if using ACF blocks.

Maybe worth considering using wp-graphql-content-blocks as part of the plugins package instead?

abid-din-akqa avatar Jan 08 '24 18:01 abid-din-akqa

Hi @abid-din-akqa, thanks for opening this up!

We are actually working on integrating the [VIP Block Data API plugin](https://github.com/Automattic/vip-block-data-api into the plugin package for the VIP Decoupled Bundle, which would do exactly what you are hoping for.

VIP Decoupled Bundle: This PR will add the Block Data API to the VIP Decoupled Bundle, so that you'd be able to retrieve the blocks in a post in a JSON format via a GraphQL API and a Rest API. This would allow you to use that as the source of truth, rather than the html as a string approach done via our bespoke content blocks plugin.

This template: We are also working on updating this template to show how the above change can be taken advantage of as well. We have some snippets of code in the VIP Block Data API's readme already, that can be used in the interim as an example.

I'll update this issue, as we complete each step in this process.

ingeniumed avatar Jan 10 '24 00:01 ingeniumed

@ingeniumed The Block Data API looks like it'll be helpful!

We ended up creating custom Blocks using ACF Blocks, so adapted the boilerplate to work in conjunction with wp-graphql-content-blocks and wpgraphql-acf.

This approach allowed us to define custom Blocks and their fields entirely using ACF, sparing us having to code a corresponding CMS block for each component.

abid-din-akqa avatar Jan 10 '24 01:01 abid-din-akqa

@abid-din-akqa, are you open to a conversation about the choice to use ACF blocks vs. native blocks? It would be super helpful to me.

If so I'll reach out via email.

smithjw1 avatar Jan 10 '24 17:01 smithjw1

@smithjw1 Absolutely! Feel free to shoot me an Email and I'd be happy to talk you through our approach.

abid-din-akqa avatar Jan 10 '24 18:01 abid-din-akqa