{% extends "_layouts/cp" %} {% import "_includes/forms" as forms %} {% set fullPageForm = true %} {% set title = "Token Scopes"|t %} {% set crumbs = [ {'label': 'Settings', 'url': url('settings')}, {'label': 'Plugins', 'url': url('settings/plugins')}, {'label': 'CraftQL', 'url': url('settings/plugins/craftql')}, ] %} {% set content %}

Try it out

You can explore your API with the permissions of this token in GraphiQL.


Name

{{ forms.textField({ first: true, name: 'token[name]', value: token.name, instructions: 'A descriptive label for this token', }) }}

Query Fields

Enable top level GraphQL fields when accessed through this token.

Field Name Description
sites Query any sites. {{ forms.lightswitch({"name": "scope[query:sites]", "value": 1, "on": token.can('query:sites'), "small": true}) }}
entries Query any entry type that is enabled, below. {{ forms.lightswitch({"name": "scope[query:entries]", "value": 1, "on": token.can('query:entries'), "small": true}) }}
entries.author Access to users through an entries author field {{ forms.lightswitch({"name": "scope[query:entry.author]", "value": 1, "on": token.can('query:entry.author'), "small": true}) }}
assets Query any assets. {{ forms.lightswitch({"name": "scope[query:assets]", "value": 1, "on": token.can('query:assets'), "small": true}) }}
globals Query any globals. {{ forms.lightswitch({"name": "scope[query:globals]", "value": 1, "on": token.can('query:globals'), "small": true}) }}
categories Query any category. {{ forms.lightswitch({"name": "scope[query:categories]", "value": 1, "on": token.can('query:categories'), "small": true}) }}
tags Query any tag. {{ forms.lightswitch({"name": "scope[query:tags]", "value": 1, "on": token.can('query:tags'), "small": true}) }}
users Query the Craft users. Note: this only affects the ability to search users. {{ forms.lightswitch({"name": "scope[query:users]", "value": 1, "on": token.can('query:users'), "small": true}) }}
users.permissions Query a user’s permissions.ยข {{ forms.lightswitch({"name": "scope[query:userPermissions]", "value": 1, "on": token.can('query:userPermissions'), "small": true}) }}
sections Query the sections (and nested Entry Types) that have been enabled below. {{ forms.lightswitch({"name": "scope[query:sections]", "value": 1, "on": token.can('query:sections'), "small": true}) }}
fields Query a field's instructions and options. Note: this will return all fields, regardless of whether it is used in an entry type that has been disabled. {{ forms.lightswitch({"name": "scope[query:fields]", "value": 1, "on": token.can('query:fields'), "small": true}) }}

Queries

Only the enabled entry types will be visible in the GraphQL schema.

{% for section in craft.app.sections.allSections %} {% for entryType in section.entryTypes %} {% endfor %} {% endfor %}
Type Section Entry Type
{{ section.type|ucfirst }} {{ section.name }} {{ entryType.name }} {{ forms.lightswitch({"name": "scope[query:entryType:" ~ entryType.id ~ "]", "value": 1, "on": token.can("query:entryType:" ~ entryType.id), "small": true}) }}

Mutation Fields

Enable top level GraphQL mutations when accessed through this token.

Field Name Description
users Add and update users {{ forms.lightswitch({"name": "scope[mutate:users]", "value": 1, "on": token.can("mutate:users"), "small": true}) }}
user.permissions Set user permissions {{ forms.lightswitch({"name": "scope[mutate:userPermissions]", "value": 1, "on": token.can("mutate:users"), "small": true}) }}
globals Update global field sets {{ forms.lightswitch({"name": "scope[mutate:globals]", "value": 1, "on": token.can("mutate:globals"), "small": true}) }}

Mutations

Enable the entry types that should be editable through GraphQL.

{% for section in craft.app.sections.allSections %} {% for entryType in section.entryTypes %} {% endfor %} {% endfor %}
Type Section Entry Type
{{ section.type|ucfirst }} {{ section.name }} {{ entryType.name }} {{ forms.lightswitch({"name": "scope[mutate:entryType:" ~ entryType.id ~ "]", "value": 1, "on": token.can("mutate:entryType:" ~ entryType.id), "small": true}) }}
{#

Throttling

Throttling is handled by calculating the "cost" of a GraphQL query. The cost is determined by the total possible elements returned by a query. For example a call to { entries { ... } } will cost 100 points because, unbounded, the entries field is limited to 100 results. If you pass { entries(limit:5) { ... } } then the cost will only be 5 points.. Throttling limits are per hour.

{{ forms.textField({ first: true, name: 'token[throttling]', value: 50000, }) }}
#} {% endset %} {% set extraPageHeaderHtml %} {% endset %}