Description
We are using the asPreview parameter on our project to enable users to preview changes they make to posts and pages.
While the query itself is mostly correct, the featured image does not take the asPreview attribute into account and always displays the last published value instead of the draft one.
Steps to reproduce
- Create a post, set a featured image and publish it
- Edit the post, change title and featured image
- Click the "Preview" button
- In the GraphiQL IDE paste the sample query below.
The result has the updated title but the featured image (databaseID and src) are incorrect.
Additional context
Sample query
{
post(id: 116, idType: DATABASE_ID, asPreview: true) {
title
featuredImageDatabaseId
featuredImage {
node {
id
databaseId
medium: sourceUrl(size: LARGE)
}
}
}
}
Result
"post": {
"title": "Etiam imperdiet imperdiet orci?",
"featuredImageDatabaseId": 73,
"featuredImage": {
"node": {
"id": "cG9zdDo3Mw==",
"databaseId": 73,
"medium": "http://local.test/wp-content/uploads/2022/11/alexander-shatov-PHH_0uw9-Qw-unsplash-scaled.jpg"
}
}
}
Expected
"post": {
"title": "Etiam imperdiet imperdiet orci?",
"featuredImageDatabaseId": 81,
"featuredImage": {
"node": {
"id": "cG9zdDo4MQ==",
"databaseId": 81,
"medium": "http://local.test/wp-content/uploads/2022/11/mike-meyers-haAxbjiHds-unsplash-scaled.jpg"
}
}
}
WPGraphQL Version
1.13.6
WordPress Version
6.1.1
PHP Version
8.0
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.
Description
We are using the
asPreviewparameter on our project to enable users to preview changes they make to posts and pages.While the query itself is mostly correct, the featured image does not take the asPreview attribute into account and always displays the last published value instead of the draft one.
Steps to reproduce
The result has the updated title but the featured image (databaseID and src) are incorrect.
Additional context
Sample query
Result
Expected
WPGraphQL Version
1.13.6
WordPress Version
6.1.1
PHP Version
8.0
Additional enviornment details
No response
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.