-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Added CoreListItem Block and updated CoreList block #331
Conversation
…elds so you can recursively get child list items
🦋 Changeset detectedLatest commit: 0793285 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my 2c, but I really don't like this as a solve (the concept - not the code).
It's already problematic for stability/compat whenever we got to manually deviate from core, but in this case there is already an existing way to get CoreListItem blocks without any of this: the regular editorBlocks( flat = $flat ) {}
fleid.
Per my comment in #253 (comment), the way to take that issue off the board is to update Faust to include a new CoreListItem component and fixing CoreList to support children.
@colinmurphy I'm swamped ATM on SnapWP, but check your discord DMs for code snippets of how we're handling core-list/core-list-item with the current version of WPGraphQL Content Blocks |
Thanks @justlevine for the feedback. I will review what you sent on Discord and make changes accordingly 👍 |
@justlevine and @theodesp Can you review again please. For me if you run the following query you get valid HTML within the renderedHtml block for the CoreListItem query postQuery($id: ID!) {
post(id: $id, idType: DATABASE_ID, asPreview: false) {
title
editorBlocks(flat: false) {
name
... on CoreList {
type
name
renderedHtml
innerBlocks {
... on CoreListItem {
type
name
renderedHtml
}
}
}
}
}
} {
"data": {
"post": {
"title": "Hello world!",
"editorBlocks": [
{
"name": "core/list",
"type": "CoreList",
"renderedHtml": "\n<ol class=\"wp-block-list\">\n<li>List item 1</li>\n\n\n\n<li>List item 2\n<ul class=\"wp-block-list is-style-default\">\n<li>Child list item 1\n<ul class=\"wp-block-list\">\n<li>Third level list item</li>\n</ul>\n</li>\n\n\n\n<li>Child list item 2</li>\n</ul>\n</li>\n\n\n\n<li>List item 3</li>\n\n\n\n<li>List item 4</li>\n</ol>\n",
"innerBlocks": [
{
"type": "CoreListItem",
"name": "core/list-item",
"renderedHtml": "\n<li>List item 1</li>\n"
},
{
"type": "CoreListItem",
"name": "core/list-item",
"renderedHtml": "\n<li>List item 2\n<ul class=\"wp-block-list is-style-default\">\n<li>Child list item 1\n<ul class=\"wp-block-list\">\n<li>Third level list item</li>\n</ul>\n</li>\n\n\n\n<li>Child list item 2</li>\n</ul>\n</li>\n"
},
{
"type": "CoreListItem",
"name": "core/list-item",
"renderedHtml": "\n<li>List item 3</li>\n"
},
{
"type": "CoreListItem",
"name": "core/list-item",
"renderedHtml": "\n<li>List item 4</li>\n"
}
]
},
{
"name": "core/paragraph"
}
]
}
}
} Let me know if I missed something. |
Closing PR as this is not needed. We will open a issue in Faust to address the issues brought up @justlevine with the core list component. |
Overview
This is a solution for the issue reported #253 whereby a user might want to recursively query child blocks.
This PR has 2 main features
Example
You have a list with 3 levels e.g.
The HTML for the block is
The following query will do the following
The response from WP GraphQL is
This should allow developers to loop through the items key and then children keys to get the value for each list item.