Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Latest commit

 

History

History
43 lines (32 loc) · 872 Bytes

checkbox.md

File metadata and controls

43 lines (32 loc) · 872 Bytes

Checkbox Field

Checkbox fields are added to the WPGraphQL Schema as a field with the Type [ 'list_of' => 'String' ].

Checkbox fields can be queried and a list (array) of Strings (the selected values) will be returned.

Here, we have a Checkbox field named checkbox on the Post Edit screen within the "ACF Docs" Field Group, and "Choice 1" is selected.

Checkbox field in the Edit Post screen

This field can be Queried in GraphQL like so:

{
  post(id: "acf-example-test", idType: URI) {
    acfDocs {
      checkbox
    }
  }
}

and the results of the query would be:

{
  "data": {
    "post": {
      "acfDocs": {
        "checkbox": [
          "choice_1"
        ]
      }
    }
  }
}