Skip to content

preview or draft page or post not working #3395

@sachithraSP

Description

@sachithraSP

Description

unable to query the draft pages. i've tried several methods to query. it's not working. when i published the page that shows the data.

query PreviewNode($id: ID!) {
preview: contentNode(id: $id, idType: DATABASE_ID, asPreview: true) {
__typename
...PageFragment
}
published: contentNode(id: $id, idType: DATABASE_ID, asPreview: false) {
__typename
...PageFragment
}
}

fragment PageFragment on Page {
id
title
}

DRAFT OUTPUT:
"data": {
"preview": null,
"published": null
},

PUBLISHED OUTPUT:
"data": {
"preview": null,
"published": {
"__typename": "Page",
"id": "cG9zdDozMzY2ODk=",
"title": "Test Page"
}
},

Steps to reproduce

query PreviewNode($id: ID!) {
preview: contentNode(id: $id, idType: DATABASE_ID, asPreview: true) {
__typename
...PageFragment
}
published: contentNode(id: $id, idType: DATABASE_ID, asPreview: false) {
__typename
...PageFragment
}
}

fragment PageFragment on Page {
id
title
}

Additional context

Image

WPGraphQL Version

2.3.3

WordPress Version

6.8.1

PHP Version

8

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    close candidateNeeds confirmation before closingobject type: userRelating to the User Typetype: questionAn issue that involve inquiries, clarifications, or requests for guidance

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions