You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On querying a posts parent info outside of preview mode everything works as expected. However when "asPreview" is passed into the query, or when the preview connection is used in the query the returned parent info equates to the current post.
For example if you have a postId of '2' that is a child of postId '1', when querying the parent of '2' outside of preview mode it returns what would be expected: '1'. When using preview mode and the same query object for postId '2' the parent id returned is now '2'.
I presume this is to do with previews / revisions and their relationship to the post they spawn from, specifically what is being set in terms of the parent information when a preview is requested.
Please see attached screenshots for the current behaviour.
Steps to reproduce
If given the above example of page '2' being a child of page '1', the below query should return '1' when targeting page.parent.id. Currently it returns the id of the original version of the previewed page.
query MyPageQuery {
page(id: 2, idType: DATABASE_ID, asPreview: true) {
databaseId
title
parent {
node {
... on Page {
databaseId
title
}
}
}
}
}
Additional context
No response
WPGraphQL Version
1.19.0
WordPress Version
6.4.2
PHP Version
8.2.10
Additional environment details
No response
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have disabled ALL plugins except for WPGraphQL.
Yes
My issue is with compatibility with a specific WordPress plugin, and I have listed all my installed plugins (and version info) above.
The text was updated successfully, but these errors were encountered:
What you're describing is intentional behavior (due to how post revisions are stored, like you mentioned), and is documented as such in the description for the asPreview arg (which is sadly not the most discoverable).
You can find the active discussion around this behavior and a workaround in #2876 .
@justlevine Thanks for your reply, I had already figured a work-around using the revisionOf prop to traverse the true parent structure for the post. However this is just that, a "workaround" and I was wondering if there were any plans to reintroduce expected behaviour for the parent prop when preview is concerned. Surely the previewOf prop suggested by Jason in the linked post #2876 would make more sense to house the info currently returned in the parent prop? I'm just not sure changing the return value / behaviour of a prop based on a variable, such as preview, makes logical sense.
Description
On querying a posts parent info outside of preview mode everything works as expected. However when "asPreview" is passed into the query, or when the preview connection is used in the query the returned parent info equates to the current post.
For example if you have a postId of '2' that is a child of postId '1', when querying the parent of '2' outside of preview mode it returns what would be expected: '1'. When using preview mode and the same query object for postId '2' the parent id returned is now '2'.
I presume this is to do with previews / revisions and their relationship to the post they spawn from, specifically what is being set in terms of the parent information when a preview is requested.
Please see attached screenshots for the current behaviour.
Steps to reproduce
If given the above example of page '2' being a child of page '1', the below query should return '1' when targeting
page.parent.id
. Currently it returns the id of the original version of the previewed page.Additional context
No response
WPGraphQL Version
1.19.0
WordPress Version
6.4.2
PHP Version
8.2.10
Additional environment 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.
The text was updated successfully, but these errors were encountered: