Skip to content
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

feat: Block object attributes may have custom types with subfields #223

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mrclay
Copy link

@mrclay mrclay commented Mar 29, 2024

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 mrclay requested a review from a team as a code owner March 29, 2024 16:47
Copy link

changeset-bot bot commented Mar 29, 2024

🦋 Changeset detected

Latest commit: cb7bbe9

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

@mrclay mrclay force-pushed the fix/support-object-properties branch from 754cc0a to cb7bbe9 Compare March 29, 2024 16:52
@mrclay mrclay changed the title feat: Add support for object properties inside block attributes feat: Block object attributes may have custom types with subfields Mar 29, 2024
@justlevine
Copy link
Contributor

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.

@theodesp
Copy link
Member

theodesp commented Apr 3, 2024

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?

@mrclay
Copy link
Author

mrclay commented Apr 3, 2024

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 mrclay marked this pull request as draft April 3, 2024 14:14
@theodesp
Copy link
Member

theodesp commented Apr 11, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support nested properties inside block.json attributes
3 participants