[ ] Chore (a non-breaking change which is related to package maintenance)
[x] Bug fix (a non-breaking change which fixes an issue)
[ ] New feature (a non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
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:
[ ] My change requires an update to the official documentation.
[x] All TSDoc comments are up-to-date and new ones have been added where necessary.
Types of changes
Description
This PR fixes a bug during previews where the
url
property in link fields always returnednull
.This happened because link fields are wrapped with
withDocumentProxy()
, which intercepts thedocument
andurl
properties to return the correct values in content relationship fields.withDocumentProxy()
was incorrectly returningnull
for all fields that are not content relationships.Note: Using
Proxy
is necessary to support content relationships and thedocument
property. In Gatsby's GraphQL API,document
refers to the linked document, which has full access to the document's data. If youconsole.log()
a link or content relationship field, you will see aProxy
object, not a standard object. This is normal.Fixes #541
Checklist: