Skip to content

Commit 7756eac

Browse files
committed
chore: review changes
1 parent 5d581cd commit 7756eac

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

gatsby-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
4747

4848
const typeDefs = [
4949
`type MarkdownRemark implements Node {
50-
socialCardFile: File @link(from: "fields.socialCard")
50+
socialCardFile: File @link(from: "fields.socialCardFileId")
5151
}`,
5252
`type SyPersonioJob implements Node {
53-
socialCardFile: File @link(from: "fields.socialCard")
53+
socialCardFile: File @link(from: "fields.socialCardFileId")
5454
}`,
5555
];
5656

gatsby/create-node/create-preview-cards.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ const createPreviewCard = async (
2020
}
2121

2222
const buffer = await generateCardToBuffer({ title });
23-
23+
/**
24+
* The util function `createFileNodeFromBuffer` from the official gatsby source plugin `gatsby-source-filesystem`
25+
* creates a file node from a given file buffer. The value of `parentNodeId` creates the necessary relationship
26+
* between the original node and the actual file node so it's not garbage collected.
27+
*
28+
* The actual foreign key relationship is resolved through `createSchemaCustomization`
29+
* in gatsby-node.js for all node types the `createPreviewCard` is invoked for.
30+
*/
2431
const fileNode = await createFileNodeFromBuffer({
2532
name: 'social-card',
2633
buffer,
@@ -33,7 +40,7 @@ const createPreviewCard = async (
3340
if (fileNode) {
3441
createNodeField({
3542
node,
36-
name: `socialCard`,
43+
name: `socialCardFileId`,
3744
value: fileNode.id,
3845
});
3946
}

0 commit comments

Comments
 (0)