- Issue created by @justclint
- πΊπΈUnited States justclint
I figured this out. Can filter by status like:
{field: "status", value: "1"}
This can be closed.
Need to query published nodes only. Didnt find anything specific here: https://graphql-core-schema.netlify.app/schema-extensions/entity-query.h...
Example query:
query queryClubGeneralEntitlements($langcode: Langcode!) {
entityQuery(
entityType: NODE
limit: 4
filter: {conditions: [{field: "type", value: "club_general_entitlement"}]}
sort: {field: "nid", direction: ASC}
revisions: DEFAULT
) {
total
items {
... on NodeClubGeneralEntitlement {
status
moderationState
fieldDataAnalyticsTag
fieldImage {
mediaFileUrl {
path
}
}
translation(langcode: $langcode) {
id
title
fieldSubtitle
body
fieldClubEntitlement {
value
}
fieldCtaLink {
title
uri {
... on DefaultUrl {
path
}
path
}
}
}
}
}
}
}
Result includes both status and moderation_state to illustrate:
{
"data": {
"entityQuery": {
"total": 2,
"items": [
{
"status": true,
"moderationState": "published",
"id": "251",
"title": "Some Entitlement 001"
},
{
"status": false,
"moderationState": "draft",
"id": "252",
"title": "Some Entitlement 002 (Draft test)"
}
]
}
}
}
1. create node type.
2. Create published and unpublished (draft) nodes.
3. Try to query only published nodes either by "revisions", "status" field or "moderation_state" field.
If I use "revisions", I will always get both published and unpublished regardless if set to ALL, DEFAULT, or LATEST.
I cant filter by "status" field because value must be a string but status is boolean.
If I filter by "moderation_state" like:
{field: "moderation_state", value: "published", operator: EQUAL}
I get internal error
For error #0: Drupal\Core\Entity\Query\QueryException: 'moderation_state' not found in Drupal\Core\Entity\Query\Sql\Tables->ensureEntityTable
What is the correct syntax to query only published nodes?
Thanks!
Active
1.0
Documentation
I figured this out. Can filter by status like:
{field: "status", value: "1"}
This can be closed.