From 39293c9ae64ee61ac4bf9d825e6690cdf74e0bdf Mon Sep 17 00:00:00 2001 From: Alex Kazhukhouski Date: Mon, 27 Jan 2025 12:48:10 +0100 Subject: [PATCH] Provides changeset file. --- .changeset/brave-dragons-laugh.md | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .changeset/brave-dragons-laugh.md diff --git a/.changeset/brave-dragons-laugh.md b/.changeset/brave-dragons-laugh.md new file mode 100644 index 00000000..dfd6d70e --- /dev/null +++ b/.changeset/brave-dragons-laugh.md @@ -0,0 +1,58 @@ +--- +"@wpengine/wp-graphql-content-blocks": minor +--- + +Adds support for specifying typed and queryable properties for object attributes in block.json. + +Example: Defining a Typed Object in `block.json`: + +```json +"attributes": { + "film": { + "type": "object", + "default": { + "id": 0, + "title": "Film Title", + "director": "Director Name", + "__typed": { + "id": "integer", + "title": "string", + "director": "string", + "year": "string" + } + } + } +} +``` + +In this example, the `film` attribute is an object with defined types for each property (`id`, `title`, `director`, and optionally `year`). + +Querying Object Properties in GraphQL: + + +```graphql +fragment Film on MyPluginFilmBlock { + attributes { + film { + id, + title, + director, + year + } + }, +} + +query GetAllPostsWhichSupportBlockEditor { + posts { + edges { + node { + editorBlocks { + __typename + name + ...Film + } + } + } + } +} +``` \ No newline at end of file