-
Notifications
You must be signed in to change notification settings - Fork 14
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
dev: Refactor attribute resolution into Data\BlockAttributeResolver
#284
dev: Refactor attribute resolution into Data\BlockAttributeResolver
#284
Conversation
|
518af63
to
253b2a3
Compare
Rebased post #279 |
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.
I pulled this down and the first query I tried to execute (just happened to have it loaded in my IDE already):
{
post(id: 121, idType: DATABASE_ID) {
id
title
date
editorBlocks(flat: false) {
__typename
...CoreTable
}
}
}
fragment CoreTable on CoreTable {
anchor
apiVersion
attributes {
textColor
style
lock
head {
cells {
align
content
tag
scope
}
}
hasFixedLayout
gradient
foot {
cells {
align
content
scope
tag
}
}
fontSize
fontFamily
className
caption
borderColor
body {
cells {
align
content
scope
tag
}
}
backgroundColor
anchor
align
}
renderedHtml
}
Led to this error:
{
"debugMessage": "WPGraphQL\\ContentBlocks\\Data\\BlockAttributeResolver::parse_query_source(): Argument #3 ($attribute_values) must be of type array, null given, called in /Users/jason.bahl/Sites/libs/wp-graphql-content-blocks/includes/Data/BlockAttributeResolver.php on line 48",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 20,
"column": 5
}
],
"path": [
"post",
"editorBlocks",
2,
"attributes",
"head"
],
"trace": [
{
"file": "/Users/jason.bahl/Sites/libs/wp-graphql-content-blocks/includes/Data/BlockAttributeResolver.php",
"line": 48,
"call": "WPGraphQL\\ContentBlocks\\Data\\BlockAttributeResolver::parse_query_source('<figure class=\"wp-block-table\"><table><thead><tr><th class=\"has-text-align-center\" data-align=\"center\">Header Label 1</th><th></th></tr></thead><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">1:1</td><td>1:2</td></tr><tr><td class=\"has-text-align-center\" data-align=\"center\">2:1</td><td>2:2</td></tr></tbody><tfoot><tr><td class=\"has-text-align-center\" data-align=\"center\">Footer Label 1</td><td>Footer Label 2</td></tr></tfoot></table></figure>', array(5), null)"
},
253b2a3
to
3314860
Compare
@jasonbahl thanks for the catch! Fixed in 7b7599f I also rebased the plugin on #290 (so |
3314860
to
1bd300a
Compare
#286 got merged directly, so the remaining relevant changes here are just the above (diff) Reminder: #290 still needs to be merged first |
1bd300a
to
3a1157b
Compare
This was merged as part of #293 |
What
This PR refactors attribute resolution handling out of
\Blocks\Block.php
and into a new\Data\BlockAttributeResolver
class.Additionally, method internals have been cleaned up and parameter/internal variables renamed for readability.
Why
controls
always return true #261 (covered by https://github.com/rtCamp/wp-graphql-content-blocks/blob/331486097e719fc8138cb5affbad9aa160ec5072/tests/unit/CoreVideoTest.php#L93 )Long term, this is part of fixing attribute resolution and performance / implementing a block
Model
. This work has been cherry-picked out for reviewability, as it contains no breaking changes or new features/fixes/enhancements.How
Block::resolve_block_attributes_recursive()
now callsData\BlockAttributeResolver::resolve_block_attribute()
. The method has been marked@internal
since' we're probably going to change it once a Block model has been fully implemented.