wp-graphql / wp-graphql-acf

WPGraphQL for Advanced Custom Fields
https://wpgraphql.com/acf
627 stars 123 forks source link

Get formatted ACF field data #368

Closed kamrulhasan2023 closed 1 year ago

kamrulhasan2023 commented 1 year ago

Hello, I am trying to get ACF field data without tagging and styling. Is it possible to get formatted data, for example : WYSIWYG field data will return an array of objects of fields serially [ { field: heading, level: 1, content: 'heading 1 " }, { field: paragraph, content: 'paragraph 1 " }, { field: heading, level: 2, content: 'heading 2 " }, ] Please let me know if there is a way to model the return data format. Thanks

Screenshot from 2023-10-10 12-46-58

jasonbahl commented 1 year ago

@kamrulhasan2023 currently, fields that return HTML will continue to return HTML. We do not currently have plans to return HTML as GraphQL object types. I think it's a cool concept, and I've seen some attempts at it, such as: https://github.com/Quartz/wp-graphql-content-blocks

And some cool write-ups on the concept, such as: https://medium.com/@wonderboymusic/the-problem-with-html-in-react-and-graphql-6af9789352f6

At the moment, we'll be returning HTML as a string, and in the future we will likely return an HTML Scalar which will probably open up new doors for both being able to modify the results before returning from WordPress, and modifying in the client after consuming an HTML field.

jasonbahl commented 1 year ago

Also, fwiw, we're re-building WPGraphQL for ACF over here: https://github.com/wp-graphql/wpgraphql-acf and will be archiving this repo in the not-too-distant future.