Logo
NeoArc Studio

Directives

Define custom directives with all 19 GraphQL locations, arguments, and repeatable support.

Directives provide a way to annotate GraphQL schema elements with additional metadata. NeoArc Studio supports all 19 GraphQL directive locations, allowing you to define and document custom directives for authentication, caching, validation, and more.

Directive Properties

Directive Locations

GraphQL defines 19 locations where directives can be applied:

Built-in Directives

GraphQL provides three built-in directives:

{
  "id": "directive-deprecated",
  "name": "deprecated",
  "description": "Marks an element as deprecated with optional reason and migration guidance.",
  "locations": [
    "FIELD_DEFINITION",
    "ARGUMENT_DEFINITION",
    "INPUT_FIELD_DEFINITION",
    "ENUM_VALUE"
  ],
  "arguments": [
    {
      "name": "reason",
      "typeName": "String",
      "nullable": true,
      "defaultValue": "No longer supported",
      "description": "Deprecation reason and migration guidance"
    }
  ],
  "isRepeatable": false,
  "isBuiltIn": true
}

Custom Directive Examples

Directive Arguments

Directive arguments allow configuration when the directive is applied:

Repeatable Directives

Set isRepeatable: true when a directive can be applied multiple times to the same element:

{
  "id": "directive-tag",
  "name": "tag",
  "description": "Adds a categorisation tag to a field or type.",
  "locations": ["FIELD_DEFINITION", "OBJECT"],
  "arguments": [
    {
      "name": "name",
      "typeName": "String",
      "nullable": false
    }
  ],
  "isRepeatable": true
}

Repeatable example in SDL:

type Product @tag(name: "commerce") @tag(name: "catalogue") {
  id: ID!
}

Applying Directives

Directives defined in the API can be applied to:

  • Operations - Via the operation's directives property
  • Arguments - Via individual argument directive arrays
  • Interfaces - Via interface and interface field directive arrays
{
  "name": "email",
  "typeName": "String",
  "nullable": false,
  "directives": [
    {
      "directiveId": "directive-sensitive",
      "arguments": {
        "reason": "Contains user email address"
      }
    }
  ]
}

Related Content