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

Can't set types of properties within an object attribute #222

Open
mrclay opened this issue Mar 29, 2024 · 1 comment
Open

Can't set types of properties within an object attribute #222

mrclay opened this issue Mar 29, 2024 · 1 comment
Labels
good first issue Issue that doesn't require previous experience with codebase help wanted Issue with a clear description that the community can help with type: feature New functionality being added

Comments

@mrclay
Copy link

mrclay commented Mar 29, 2024

Because WP doesn't define what an attribute with type object means, these attributes end up with the generic BlockAttributesObject type in this plugin, and can't be extended with register_graphql_field('MyBlock', 'film', .... If you need decent types from blocks in GraphQL, then, you just can't use nested attributes. Nested attributes would improve the authoring experience of Save/Edit components, allowing us to build up structures from subcomponents.

One solution would be for the plugin to read object properties inside attributes like:

{
  ...
  "attributes": {
    "film": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        }
        ...
      }
    }
  }
}

A workaround would be to allow the field's GraphQL type to be overridden using register_graphql_field or some other function.

@theodesp theodesp added type: feature New functionality being added good first issue Issue that doesn't require previous experience with codebase help wanted Issue with a clear description that the community can help with labels Apr 2, 2024
@mrclay mrclay changed the title Support nested properties inside block.json attributes Can't set types of properties within an object attribute Nov 27, 2024
@mrclay
Copy link
Author

mrclay commented Nov 27, 2024

I suppose I should lobby WP itself to better define its block.json schema. IMO the type object really should not mean any unstructured data type. Maybe unknown could be created for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue that doesn't require previous experience with codebase help wanted Issue with a clear description that the community can help with type: feature New functionality being added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants