Closed jasonbahl closed 8 months ago
This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
src/FieldConfig.php | 1 | 91.84% | ||
<!-- | Total: | 1 | --> |
Totals | |
---|---|
Change from base Build ece620b9f911b507d9cc9754d75449bf2879bc0e: | 0.3% |
Covered Lines: | 2093 |
Relevant Lines: | 3285 |
What does this implement/fix? Explain your changes.
This fixes a bug where Image fields (and other fields that return Connections) were not properly resolving when querying a page
asPreview: true
.In order to support preview resolution, all field names and keys are tracked and then during resolution filters are applied to ensure the meta is resolved properly for each field (either the published post or the preview post).
Fields that return Connection types were not properly being tracked in this registry, leading to the preview resolver filter not being applied for these fields, so they would return preview data from the published node instead of the preview node.
Does this close any currently open issues?
closes #187
Any other comments?
I published a page with the following image uploaded for the image fields:
http://uri-debugging.local/wp-content/uploads/2024/03/1920x1080.png
When I query the page with
asPreview: false
I see the image returned as expected:When I query the page as an authenticated user with
asPreview: true
, I see the published image value (expected, since I have not made any un-published changes yet):Now, if I go replace the image:
http://uri-debugging.local/wp-content/uploads/2024/03/1920x1080.png
http://uri-debugging.local/wp-content/uploads/2024/03/andrea-de-santis-kq3hRVDiYYY-unsplash-scaled.jpg
And query
asPreview: true
again:BEFORE
I still see the published image, not the preview image. 😭
AFTER
I see the image that was added to the preview but not yet published! 🥳