Hey @Fares,
Thanks for getting back to me so quickly, I appreciate it. I realised I forgot to mention possibly a key detail – I'm building the site out using the gatsby-source-prismic
plugin, and I'm following the instructions for the fetchLinks / graphQuery code here: Gatsby Migration Guide: gatsby-source-prismic V3 to V4 - Prismic
Here's an excerpt of my gatsby-config.js
file:
{
resolve: "gatsby-source-prismic",
options: {
repositoryName: process.env.GATSBY_PRISMIC_REPO_NAME,
accessToken: process.env.PRISMIC_ACCESS_TOKEN,
customTypesApiToken: process.env.PRISMIC_CUSTOM_TYPES_API_TOKEN,
graphQuery: `
{
product {
artwork
}
}
`,
linkResolver: require(`./src/components/link-resolver/linkResolver`)
.linkResolver,
},
},
And my linkResolver looks like the following:
exports.linkResolver = (doc) => {
// URL for a product type
if (doc.type === "product") {
console.log(doc);
return `/${doc.data.artwork.handle}/`;
}
// Backup for all other types
return `/${doc.uid}/`;
};
What I want to be able to do is take the Shopify product handle and set that as the generated uid for the product, rather than the Prismic Product uid, if that makes sense?
But currently when I console.log(doc) as above, the following data is returned, without any of the Shopify integration field data (which should be displayed underneath artwork
on the last line:
{
link_type: 'Document',
id: 'b48fd90d-89f5-5d9c-930c-456ce2e7e7ad',
uid: 'hockney-test-artwork',
type: 'product',
tags: [],
lang: 'en-gb',
url: undefined,
slug: 'hockney-test-artwork',
data: { artwork: '86ff8e84-aac5-543a-b005-45f6285c43f6' }
}
It's very possible that what I want to do isn't possible, but I just wanted to see if it was.
Let me know if you need any other details / clarification.
Thanks!