verbb / tablemaker

A user-definable table field type for Craft CMS
MIT License
40 stars 32 forks source link

Unable to retrieve the column type using GraphQL #40

Closed benfeather closed 10 months ago

benfeather commented 10 months ago

What are you trying to do?

When retrieving values from the GraphQL API, it is not possible to determine the field type assigned to the column.

For example, if I have a table configured like this: CleanShot 2024-01-25 at 11 26 18@2x

And request the data using GraphQL, this is the response: CleanShot 2024-01-25 at 11 23 27@2x

What's your proposed solution?

Add a "type" property to the table columns that outputs the field type. Using the example above, the output would be:


{
  "table": {
    "rows": [
      ["1", "1", "1", "1"],
      ["0", "0", "", ""]
    ],
    "columns": [
      {
        "heading": "Number",
        "type": "number"
      },
      {
        "heading": "Text",
        "type": "text"
      },
      {
        "heading": "Checkbox",
        "type": "checkbox"
      },
      {
        "heading": "Switch",
        "type": "switch"
      }
    ]
  }
}
engram-design commented 10 months ago

Added for the next release. To get this early, run composer require verbb/tablemaker:"dev-craft-4 as 4.0.7".

benfeather commented 10 months ago

Legend. Works perfectly.