prismicio / prismic-gatsby

Gatsby plugins for building websites using Prismic
https://prismic.io/docs/technologies/gatsby
Apache License 2.0
313 stars 96 forks source link

fix(previews): correctly resolve the `url` property in link fields #542

Closed angeloashmore closed 1 year ago

angeloashmore commented 1 year ago

Types of changes

Description

This PR fixes a bug during previews where the url property in link fields always returned null.

This happened because link fields are wrapped with withDocumentProxy(), which intercepts the document and url properties to return the correct values in content relationship fields. withDocumentProxy() was incorrectly returning null for all fields that are not content relationships.

Note: Using Proxy is necessary to support content relationships and the document property. In Gatsby's GraphQL API, document refers to the linked document, which has full access to the document's data. If you console.log() a link or content relationship field, you will see a Proxy object, not a standard object. This is normal.

Fixes #541

Checklist: