-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The content (fields) of a node are a combination of whatever is retrieved from the Umbraco API and Gatsby's node metadata. (With some slight modifications for file and FK fields.) But what happens when the name of a field fetched from the API collides with the name of a reserved Gatsby internal field?
Looking at the loadNode function in load-umbraco-nodes.js, the data is merged with the metadata object. I guess the metadata field will overwrite the one from the regular data. (See lines 31-34.)
gatsby-source-umbraco/lib/load-umbraco-nodes.js
Lines 24 to 41 in 8b2fd98
| async function loadNode(helpers, sitemapNode, parent) { | |
| const { gatsby } = helpers | |
| const data = await fetchDataForSitemapNode(helpers, sitemapNode) | |
| const nodeMeta = createGatsbyNodeMeta(gatsby, data, sitemapNode, parent) | |
| let fields = await loadRemoteFiles(helpers, data, nodeMeta) | |
| fields = handleForeignKeyFields(helpers, fields) | |
| const node = { | |
| ...fields, | |
| ...nodeMeta, | |
| } | |
| gatsby.actions.createNode(node) | |
| registerType(node.internal.type) | |
| if (parent) gatsby.actions.createParentChildLink({ parent, child: node }) | |
| return node | |
| } |
This is fine, honestly. As long as the developer working with it knows about what is happening and why.
I've seen other plugins replace the overlapping field name by appending some sort of _normalized suffix to it. That way the data will always show up.
It would probably be best to log a warning to the developer, indicating that the plugin encountered a duplicate/reserved field name and how it will handle it. That way the developer can choose to rename the field. (The warning would tell the developer what is happening and why 😄)