Closed brandonweiss closed 4 years ago
What we do here is create a new node that ties this field to that new file node that is created. You may just need to restart the gatsby develop
if you haven't. I don't think this will rebuild itself save (e.g. hot reloading).
You will likely go from a node that mirrors the JSON data Airtable would send like below:
to a node with a localFiles
:
The localFiles
will contain that file node that you are seeing in your query of allAirtableField
. My assumptions may very well be wrong, but please let me know if this helps.
Hmm, I don’t seem to have a localFiles
field 🤔
I dug through the code and I can see that there is a conditional where you check if there are any local files before creating that field.
But I just traced it through and the localFiles___NODE
property is getting set to an array containing the node’s ID. So it seems like it should work… 🤔
Hmm, part of me wonders if it is specifically an issue with a svg? I see your example using it.
Or wait, I think I misunderstood. What I was looking at is the new node for the “AirtableField” being created? But when I look at processedData
in checkChildNode
, I can see that it has the link:
{
logo___NODE: '16f22541-3d66-5a9f-902d-7215f455e333'
}
It seems like it should work?
Ach, I misunderstood on what node the localFiles
field was supposed to be. Sorry, I’m a bit new to Gatsby, let me start over.
The AirtableField is all good. I can see the localFiles
property. That node appears to be fine. The problem is what I originally thought. The logo
field that should be linked to the AirtableField node just isn’t there for some reason.
Hmm, maybe I found the problem?
processedData
is passed into checkChildNode
here:
processedData
is mutated to create the link here:
But if you step back out of that function, processedData
doesn’t seem to have been mutated. When I inspect it here:
It doesn’t have the logo___NODE
property.
FML. I updated some seemingly unrelated packages (gatsby-image, gatsby-plugin-sharp, and gatsby-transformer-sharp) and now it works 🙄
There is some async/promise things going on which may explain why your log didn't see it mutated. We only mutate locally to "build" up the data on the node, and when that is complete we use it to create the node.
Well, I am glad that you figured it out at least. It seems that upstream has been having a few issues and eating the true error, then giving us unhelpful remains.
Ah, that makes sense! Thanks for your help!
I’ve got a “Companies” table with an attachment field called “logo”. When I query it like this:
I get back the ID of the attachment, which is what I’d expect.
However, when I add a mapping in the config to try to turn it into a file node.
The “logo” field disappears off of the company node.
However, now I can see
airtableField
andallAirtableField
queries in the GraphQL explorer. If I query them:I can get the file node.
I’m not a Gatsby pro… is this what is supposed to happen? Or am I doing something wrong? 😕