Toggle Fields

THIS PAGE
In the graph
In the CMS
In the API

Toggle fields are used to store boolean or yes/no type values. They can only hold two states, true or false.

In the graph

Screenshot

Create a toggle field by simply creating a new field and marking the input type as Toggle.

Additional Properties

Property Description
Default The default value for this field.

Validations

The toggle doesn't support any validations

In the CMS

Screenshot

When you publish a toggle field, it's available in the Content Management System as a toggle input. The user can click on the toggle to alternate between the true and false states.

In the API

In the API the output response for this field is a boolean value.

Sample GraphQL Request

{
  movies {
    title
    isActive # Marked as a toggle field
  }
}

Sample GraphQL Response

{
  "data": {
    "movies": [
      {
        "title": "Superman vs. Spiderman",
        "isActive": true
      },
      {
        "title": "Superman vs. Spiderman 2",
        "isActive": false
      }
    ]
  }
}
Did you find what you were looking for?
👍
👎
What went wrong?
Need more help?We have a thriving Discordcommunity that can help you with all things Canonic. →