-
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
CoreImageAttributes.width
is type String
, but should be a Float
#136
Comments
From a search of WordPress's codebase, it seems, the Column and Spacer blocks are the only one that use a As mentioned, I'm unclear where this is being handled in the code and I don't see a particular PR that made this fix, but my suggestion would be to parse the width into a |
Hey @justlevine. After a conversation with @jasonbahl, we found that this is indeed inconsistent. Could you open a PR for this? There is a test case that needs to addressed here when you revert this back to If you haven't got availability, I will create a ticket and follow up. Thanks. |
I have some availability over the weekend but I'm not entirely sure I understand this plugin's lifecycle. If you link me to the parts that are currently responsible for fetching/parsing the block attributes, I'd be happy to take a stab at it 😁 |
Sure. It's this line need to be removed: https://github.com/wpengine/wp-graphql-content-blocks/blob/main/includes/Blocks/CoreImage.php#L32 It will default back to |
It's the attribute fetching/parsing_ that I'm looking for. I need that in order to take the original string |
You can still specify both explicitly:
The type parsing is located here: However we don't handle enum types yet. https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#enum-validation Implementing this would be outside the scope of this ticket. |
This is a major pain when working with something like GraphQL Codegen for TypeScript types. I see this problem in several places throughout the attributes for the Core blocks: CoreAudioAttributes on CoreAudio:
CoreColumnAttributes on CoreColumn
CoreCoverAttributes on CoreCover
CoreFileAttributes on CoreFile
CoreImageAttributes on CoreImage
CoreNavigationLinkAttributes on CoreNavigationLink
CoreNavigationSubmenuAttributes on CoreNavigationSubmenu
CorePageListItemAttributes on CorePageListItem
CorePostFeaturedImageAttributes on CorePostFeaturedImage
CoreSiteLogoAttributes on CoreSiteLogo
CoreSocialLinksAttributes onCoreSocialLinks
CoreSpacerAttributes on CoreSpacer
CoreTextColumnsAttributes on CoreTextColumns
CoreVideoAttributes on CoreVideo
|
@LarsEjaas the root cause /solution for all these is likely similar. Apart from |
I am not sure what they should be actually. But for me, the main issue is that the types are different depending on where I make a query for the blocks. Example: |
I noticed that this would happen on each fragment that contains the same attribute name but different type. For example:
One potential solution is to use unique aliases for each fragment CorePostFeaturedImageFragment on CorePostFeaturedImage {
corePostAttributes: attributes {
width
}
}
fragment CoreSiteLogoFragment on CoreSiteLogo {
coreSiteLogoAttributes: attributes {
width
}
}
{
posts {
nodes {
editorBlocks {
name
__typename
...CorePostFeaturedImageFragment
...CoreSiteLogoFragment
}
}
}
} |
Noticing that the
width
field onCoreImageAttributes
is typeString
when it should be of typeFloat
:I'm not 💯sure how this plugin is automating the
{BlockType}Attributes
field registration, otherwise I'd open a PR myself.The text was updated successfully, but these errors were encountered: