-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Add support for CoreNavigation blocks #334
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
Conversation
🦋 Changeset detectedLatest commit: 61b1ccf 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.
My personal opinion here is the same as on #331 (review) - and will be any time a PR:
- registers a custom field to a Block (maintainability, forward-compat).
- calls
render_block()(performance, bugs from rerendering)
Doubly true here, when (like with CoreList), CoreNavigationLink is already available using the proper pattern of innerBlocks / flatListToHierarchical().
TBH innerBlocks does not render anything for me: IF you look at the actual resolved block data its just this. There is nothing there except the So if we could expose the list of innerBlocks by just returning the parsed list of blocks from the CoreNavigation. Is there a better way you think? |
If it's not working on With that in mind, I'd even go so far as to say "let If you do need to handle it in the interim - my recommendation would be to populate it Even if worst case you add another |
whoami-pwd
left a comment
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 a couple of minor code related issues here that we can improve.
whoami-pwd
left a comment
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.
Nice work 👍🏻
Just a couple of minor suggestions.
Co-authored-by: Alex K. <[email protected]>


Summary
This PR adds support for resolving and returning navigation items within the CoreNavigation block for WPGraphQL Content Blocks. The implementation parses the referenced navigation post and returns a list of block types (EditorBlock) representing the inner blocks of the navigation.
Note
The implementation does not consider the list of allowed blocks so we do not do any validation checks as we rely on Gutenberg logic.
Usage Example
With this update, the GraphQL query below is now supported:
{ posts { nodes { editorBlocks { ... on CoreNavigation { type name innerBlocks { type name } attributes { ref } } } } } }The
navigationItemsfield will return a list of parsed blocks from the referenced navigation post, which includes nested block types likeCoreNavigationLink.Example Response
{ "data": { "posts": { "nodes": [ { "editorBlocks": [ { "type": "CoreNavigation", "name": "core/navigation", "innerBlocks": [ { "type": "CorePageList", "name": "core/page-list" }, { "type": "CoreNavigationLink", "name": "core/navigation-link" } ], "attributes": { "ref": 31 } }, {}, {}, {} ] }, { "editorBlocks": [ {} ] } ] } }, }