Closed angeloashmore closed 3 years ago
Can you give more context over why this change? Looks like to me this create inconsistencies regarding what document object the link resolver will receive, maybe I missed something.
Okay, after some thoughts I got it, that's quite farfetched as assuming your link resolver might receive links with a data object can be dangerous but I'm fine with it ☺️
Ah sorry, forgot to come back to your question. Yes, this is to cover the case where your Link Resolver expects data
to be populated with content using fetchLinks
or graphQuery
. For example, if you query for a Page document with a parent
field, you may have your client setup to fetch data for the parent document.
The change described above allows documentToLinkField
to be inline with that functionality.
If a use case is needed for reference, documentToLinkField
is used in gatsby-source-prismic
where the Link Resolver must act exactly like it does elsewhere, such as in Rich Text fields.
If a document is provided to
documentToLinkField
for use withasLink
, the document'sdata
field should be retained.Related issue: https://github.com/prismicio/prismic-types/issues/1
documentToLinkField
currently copies all standard Link fields exceptdata
, which may be populated in normal Fields using fetchLinks or GraphQuery.https://github.com/prismicio/prismic-helpers/blob/6dec3ab22bb5f29b26846aa52b9e6ce0a40034f5/src/documentToLinkField.ts#L18-L27