Support for Metadata fields and Misc Data #24
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @pasdo501
I have been working on a ecom site with Gatbsy and WooCommerce.
I have been using this plugin to feed my site with the WooCommerce info, but I found an issue, where the products metadata is not arriving properly.
In particular Yoast SEO config.
Basically what occurs is that metadata is arriving but not the metadata.value.
I'm not a GraphQL expert, but I assumed the error occur because the metadata value type varies.
In some cases it is a string, in others a number and in others an array.
In order to solve that, I have standardize the metadata field to always be a string array.
Also, I found another issue in specific when querying misc data such as
data/countries
where the data is not successfully returned, because they have no ids.I'm no Wordpress expert either, but seems that this information is not stored in database, rather in files.
And due to the this, all the nodes comes without an id.
I have modified the process so that in the cases where the nodes have no ids, it can compute an id based on a
code
property and the field name. Exampledatacountries/USA
.I have also created some unit testing for the new code.
I have decided to add a new file called
misc_data.js
to not add additional logic to the current helper file.Final comment, I'm seeing several formatting changes on the
gatsby-node
file, although I just added the usage ofgetWCNodeId
andmapNodeNormalizeMetadata
, I'm wondering now if my IDE did those automatically.