Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Sep 5, 2023

Conversation

angeloashmore
Copy link
Member

@angeloashmore angeloashmore commented Sep 5, 2023

Types of changes

  • Chore (a non-breaking change which is related to package maintenance)
  • 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.
  • All TSDoc comments are up-to-date and new ones have been added where necessary.
  • All new and existing tests are passing.

@angeloashmore angeloashmore merged commit 0a426c5 into main Sep 5, 2023
10 checks passed
@angeloashmore angeloashmore deleted the aa/fix-link-url-fields branch September 5, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't access data inside link fields when in a preview session
1 participant