-
Notifications
You must be signed in to change notification settings - Fork 17
Description
β οΈ DisclaimerThis is a [stub] follow-up to #136 , as @moonmeister encouraged me to start backfilling some of my bigger wish-list items instead of keeping them all for myself π
Problem
Currently, Block fields and attributes are registered directly on each block type. This causes several issues:
- Bloated schema / queries / userland codebases*, since you can't write generic fragments
- Schema conflicts / inconsistencies, as different blocks implement the same value as different types ( e.g. an int vs a string
attributes.height) - Prone to breaking on Gutenberg updates (e.g when they notice and patch those type discrepancies)
- Suboptimal DX (e.g instead of an int or a string,
attributes.heightshould be aCssMeasurement<{$size}{$unit}>)
Solution
*BlockAttribute Object types should implement GraphQL Interfaces per their Block Supports, and use that as the stable source of truth for those parts of the schema going forward.
Then and only where there is a conflict between the interfaces and what's inferred from the block.json we can coerce it on the block resolver level. The same approach can also:
- provide stability and future-proofing (by coercing any values resolved via the interface),
- allow for multiversion-backcompat (it's just another conditional in the resolver)
- (eventually) provide a path for improved subjective DX, without it becoming additional tech-debt (due to the previous two points).
For example (I suck at naming things, so giving a few different styles. These are illustrative only):
- BlockAttributesSupportsTypographyFontSize
- BlockSupportsColorHeading
- FilterDuotoneBlockSupportAttributes
You can see some exploratory work to this effect in rtCamp#31
Additional Notes
- Nothing here requires a breaking change to implement, and it can be implemented incrementally.
- An obvious future extension of this are interfaces for shared functionality on a Block level. E.g. image/media item connections, related terms, etc
Sub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
Status