wp-graphql-content-blocks icon indicating copy to clipboard operation
wp-graphql-content-blocks copied to clipboard

feat: Block object attributes may have custom types with subfields

Open mrclay opened this issue 10 months ago • 5 comments

If a block attribute has a "properties" key, the attribute now has a custom type with typed subfields.

Fixes #222

Obviously a big concern here is that, to my knowledge, WP haven't documented how object attribute properties should be documented in block.json. "properties" was chosen by convention in JSONSchema.

mrclay avatar Mar 29 '24 16:03 mrclay

🦋 Changeset detected

Latest commit: cb7bbe985a730c8335580e40a90d7f27c0584629

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@wpengine/wp-graphql-content-blocks Major

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

changeset-bot[bot] avatar Mar 29 '24 16:03 changeset-bot[bot]

to my knowledge, WP haven't documented how object attribute properties should be documented in block.json. "properties" was chosen by convention in JSONSchema.

Some of the public docs are indeed a mess. ICYMI here's the docs for block.json metadata and attributes. If there's something specific you're trying to verify I'm happy to help try and dig it out of the source code.

justlevine avatar Mar 29 '24 17:03 justlevine

Hey @mrclay thanks for the PR.

I read the docs and it mentions:

Note that the validity of an object is determined by your source. For an example, see the query details below.

Do we need to check with isset( $attribute['source'] before we use it or its irrelevant?

theodesp avatar Apr 03 '24 09:04 theodesp

I think defining properties without a source is just undefined in WP and we should get their team to bless and document this approach before moving forward. This PR would add API surface area that may conflict with some other approach they choose in the future.

mrclay avatar Apr 03 '24 14:04 mrclay

Hey @mrclay. Thank you for the PR. Before we review it we require a CLA agreement from you:

Contributor License Agreement

All external contributors to WP Engine products must have a signed Contributor License Agreement (CLA) in place before the contribution may be accepted into any WP Engine codebase.

  1. Submit your name and email
  2. 📝 Sign the CLA emailed to you
  3. 📥 Receive copy of signed CLA

theodesp avatar Apr 11 '24 10:04 theodesp