strapi / blocks-react-renderer

A React renderer for the Strapi's Blocks rich text editor
Other
107 stars 15 forks source link

[feat]: example with graphql data #27

Open drj8022 opened 4 months ago

drj8022 commented 4 months ago

A clear and concise description of what the feature is

This is a great plugin, thank you for putting it together! I'm trying to use this in my project, but I can't figure out how to properly query the data I need from GraphQL. If I select everything possible from a "Rich text (Blocks)" component, it only works if literally every kind of content has been added. Or if I select only the most basic elements from GraphQL it will appear "broken" when, for example, italic text is entered and the text does not appear italic. (If that makes any sense lol)

Basically if you request italic text--and there isn't any--the query breaks. If you don't request italic text--and users have entered it--the query works... but you don't get the italic text. So how do I make everything optional?

Why should this feature be included?

It will get developers using GraphQL up and running much faster. In my case, I happen to be using Gatsby. It does provide an error message linking to this page, but unfortunately I don't have enough experience with GraphQL, and there is some nesting and complexity with this plugin.

Please provide an example for how this would work

Ideally there would be a GraphQL query like this: myrichtextblocksfield { type level format image { alternativeText url } children { bold italic strikethrough text type url underline children { text type } } }

It should work whether or not supported content has been entered. Lists, bold text, underlines, images, and so on. Basically how do I create a nested type definition where everything is optional?

joshuaellis commented 4 months ago

I think this needs to be on the strapi repo. @remidej what do you think?