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

Allow querying data on CoreFootnotes

Open erikhartin opened this issue 7 months ago • 0 comments

Querying CoreFootnotes (a newish block as of WP 6.1 I believe) in the current version of wp-graphql-content-blocks returns no data. I don't know how Gutenberg stores the footnotes but it would be nice to be able to query them.

To reproduce, using a stock WP 6.6.0, create a post and insert a footnote. then query it using the following query

query PageContent {
  posts {
    nodes {
      id
      editorBlocks {
        ... on CoreFootnotes {
          apiVersion
          blockEditorCategoryName
          renderedHtml
          attributes {
            backgroundColor
            borderColor
            className
            fontFamily
            fontSize
            lock
            metadata
            style
            textColor
          }
          clientId
          cssClassNames
          isDynamic
          name
          parentClientId
          innerBlocks {
            name
            renderedHtml
          }
        }
        ... on CoreParagraph {
          anchor
          apiVersion
          attributes {
            content
          }
          name
        }
      }
    }
  }
}

For illustration I've queried every single field on CoreFootnotes.

The data returned is

{
  "data": {. 
    "posts": {. 
      "nodes": [
        {
          "id": "cG9zdDoxNg==",
          "editorBlocks": [
            {
              "anchor": null,
              "apiVersion": 3,
              "attributes": {
                "content": "hello hello<sup data-fn=\"384894a0-a54e-4b31-91f5-927e3526a5d3\" class=\"fn\"><a id=\"384894a0-a54e-4b31-91f5-927e3526a5d3-link\" href=\"#384894a0-a54e-4b31-91f5-927e3526a5d3\">1</a></sup>!"
              },
              "name": "core/paragraph"
            },
            {
              "anchor": null,
              "apiVersion": 3,
              "attributes": {
                "content": "Another block"
              },
              "name": "core/paragraph"
            },
            {
              "apiVersion": 3,
              "blockEditorCategoryName": "text",
              "renderedHtml": "",
              "attributes": {
                "backgroundColor": null,
                "borderColor": null,
                "className": null,
                "fontFamily": null,
                "fontSize": null,
                "lock": null,
                "metadata": null,
                "style": null,
                "textColor": null
              },
              "clientId": "669cb9b683b95",
              "cssClassNames": null,
              "isDynamic": true,
              "name": "core/footnotes",
              "parentClientId": null,
              "innerBlocks": []
            }
          ]
        },
        {
          "id": "cG9zdDox",
          "editorBlocks": [
            {
              "anchor": null,
              "apiVersion": 3,
              "attributes": {
                "content": "Welcome to WordPress. This is your first post. Edit or delete it, then start writing!"
              },
              "name": "core/paragraph"
            }
          ]
        }
      ]
    }
  },
  "extensions": {
    "debug": [],
    "queryAnalyzer": {
      "keys": "1aaf11c676d6acbfcfdb1d4bcd9b3e8e51453b9f24b8ef7d8c3070293c8bcdfd graphql:Query operation:PageContent list:post cG9zdDoxNg== cG9zdDox",
      "keysLength": 132,
      "keysCount": 6,
      "skippedKeys": "",
      "skippedKeysSize": 0,
      "skippedKeysCount": 0,
      "skippedTypes": []
    }
  }
}

One would expect at least renderedHtml to return the actual content of the footnote, but no dice.

Could this be supported? Footnotes are surprisingly useful and I'm happy WP finally added it as a core feature.

erikhartin avatar Jul 21 '24 07:07 erikhartin