Hello, i would like to know if we can access normalizers somewhere ?
(like normalizers in current gatsby-source-wordpress)

Hi @PierreMouchan ! Thanks for opening an issue.
This plugin works in a more nuanced way than the previous version of gatsby-source-wordpress, so the concept of a normalizer doesn't carry over super well. There is an internal API beforeChangeNode that allows you to do a similar thing, but it's not encouraged to use it currently. The reason for this other API is that we now have a few different scenarios in which data could be normalized. During initial fetch of all nodes, when a node is incrementally updated, when a brand new node is incrementally created, and when a node is incrementally deleted. In addition to normalization, you will likely need to use the schema customization API yourself to work your new data in properly. This is problematic as a general way of normalizing data. The better path here is to use a WPGraphQL extension to modify WordPress data on the WP side instead of on the Gatsby side, because if you do that all of the different scenarios are already accounted for in the source plugin.
However, if something like normalizers is needed on the Gatsby side we can work towards a happy path for it.
What's the use-case you're trying to achieve?
Also, something we've been thinking of adding is an actions/filters api that devs or plugin authors could hook into to filter various pieces of data as the source plugin or any child plugins run, or to execute arbitrary logic at specific points, similar to how WP works and similar to the concept of normalizers in the previous plugin.
The action/filters api sounds really interesting !
The use-case i'm trying to achieve is to unescape some acf string field like this one :

into this :

I was using the normalizer to unescape html entities and html code like this one before, i was forced to migrate to this experimental version due to some bug with the rest api, and so i wass looking to achieve the same behavior as my old good normalizer :)
If you have any knowledges of some wpgraphql plugin that can do that, i would gladly appreciate it ! Thank !
@PierreMouchan that makes sense. WPGraphQL will handle this in the next release automatically which is pretty great! :D This should be the default so if the next wpgql release doesn't automatically fix it for all fields for whatever reason, I'll add it into the source plugin because there are very few cases where you don't want these entities unescaped. For now you can use the beforeChangeNode api.
See https://github.com/gatsbyjs/gatsby-source-wordpress-experimental/blob/master/src/models/gatsby-api.js#L100 for an example.
So as a temporary solution you could do something like this:
gatsby-config.js
{
resolve: `gatsby-source-wordpress-experimental`,
options: {
type: {
// __all applies type settings to all types
__all: {
// this function will run any time a node of any type will be created or updated
beforeChangeNode: ({ remoteNode, actionType }) => {
if (actionType === `DELETE`) {
return
}
const nodeWithUnescapedEntities = unescapeEntities(remoteNode)
return {
remoteNode: nodeWithUnescapedEntities
}
}
}
}
}
}
@TylerBarnes Yeahhh ! I saw the PR related to this today haha ! (it's a life saver !)
Thank for the replay again ! You're amazing !
I will look at this interesting option for the moment ! Thanks !