gatsby-source-datocms: createNodeField does not create a field
Hi, I am trying to add a field to an existing DatoCMS node but it doesn’t work.
I have added this code in the file gatsby-node.js:
exports.onCreateNode = ({ node, actions }) => {
const { createNodeField } = actions
if (node.internal.type === "DatoCmsPerson") {
// console.log(node) // the node extists
createNodeField({
node,
name: "hello",
value: "hello!!!",
})
}
}
Any ideas why I don’t see the field in GraphiQL?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 31 (11 by maintainers)
May I write down the updated code snippet in the final post so people could reference.
The query above will fetch a copy of the file (file URL specified in
video_id) into your local build folder, using createRemoteFileNode, during build-time.Reopening!
@PatrykRudzinski the caching done by
gatsby-source-filesystemis here and hereAs you can see, when a file is received with a status of
200, it will be stored in Gatsby’s.cachedirectory (in this case,.cache/caches/gatsby-source-filesystem). The headers from the file response will be stored in the node cache.With headers cached, the next request for the same url will use
If-None-Match: "<cached etag>". If the file has not changed, the server should respond with a304. That means a network request is still going out, but it should not be downloading anything. It simply moves on, storing the cached file’s path on the file node in Gatsby’s GraphQL layer here@PatrykRudzinski I am a free user of the datocms and I built a very small gatsby website so cache is not my priority. I guess @matjack1 would give you a perfect support on your question.
Just my two cent, I guess the caching mechanism, if there is one, should be done by Gatsby. This plugin, for my understanding, is to fetch the content from DatoCMS to your local drive for Gatsby to build.