Logo
NeoArc Studio

Interfaces

Define GraphQL interfaces for type contracts with fields, inheritance, and directive support.

GraphQL interfaces define contracts that object types must implement. Interfaces specify a set of fields that implementing types must include, enabling polymorphic queries and consistent field access across related types.

Interface Properties

Common Interface Patterns

Interface Fields

Fields on interfaces define the contract that implementing types must satisfy:

{
  "id": "interface-searchable",
  "name": "Searchable",
  "description": "Types that support full-text search",
  "fields": [
    {
      "id": "field-search-content",
      "name": "searchContent",
      "typeName": "String",
      "nullable": false,
      "description": "Concatenated searchable text content"
    },
    {
      "id": "field-search-highlights",
      "name": "searchHighlights",
      "typeName": "[String!]",
      "nullable": true,
      "description": "Highlighted search matches",
      "arguments": [
        {
          "id": "arg-query",
          "name": "query",
          "typeName": "String",
          "nullable": false,
          "description": "Search query to highlight"
        }
      ]
    }
  ]
}

Interface Inheritance

Interfaces can extend other interfaces using the implementsInterfaces property:

{
  "id": "interface-content",
  "name": "Content",
  "description": "Base interface for all content types",
  "implementsInterfaces": ["Node", "Timestamped"],
  "fields": [
    {
      "id": "field-content-title",
      "name": "title",
      "typeName": "String",
      "nullable": false
    },
    {
      "id": "field-content-slug",
      "name": "slug",
      "typeName": "String",
      "nullable": false
    }
  ]
}

The Content interface requires implementing types to include:

  • Fields from Node: id
  • Fields from Timestamped: createdAt, updatedAt
  • Its own fields: title, slug

Directives on Interfaces

Apply directives to interfaces and their fields:

{
  "id": "interface-legacy-entity",
  "name": "LegacyEntity",
  "description": "Interface for legacy system entities being migrated",
  "directives": [
    {
      "directiveId": "deprecated",
      "arguments": {
        "reason": "Use ModernEntity interface instead. Will be removed in v3.0."
      }
    }
  ],
  "fields": [
    {
      "id": "field-legacy-code",
      "name": "legacyCode",
      "typeName": "String",
      "nullable": false,
      "directives": [
        {
          "directiveId": "deprecated",
          "arguments": {
            "reason": "Use 'id' field instead"
          }
        }
      ]
    }
  ]
}

Editor Interface

The Interfaces editor provides:

  • Interface List - Add, edit, and remove interfaces
  • Field Management - Add fields with type configuration
  • Implements Selector - Choose interfaces to extend (excludes self)
  • Directives Panel - Apply directives to interfaces and fields

Complete Interface Example

{
  "id": "interface-article",
  "name": "Article",
  "description": "Interface for article-type content including blog posts, news items, and documentation pages.",
  "implementsInterfaces": ["Node", "Content", "Publishable"],
  "fields": [
    {
      "id": "field-article-body",
      "name": "body",
      "typeName": "String",
      "nullable": false,
      "description": "Article body content in HTML or Markdown"
    },
    {
      "id": "field-article-excerpt",
      "name": "excerpt",
      "typeName": "String",
      "nullable": true,
      "description": "Short summary for previews and SEO",
      "arguments": [
        {
          "id": "arg-max-length",
          "name": "maxLength",
          "typeName": "Int",
          "nullable": true,
          "defaultValue": "200",
          "description": "Maximum excerpt length"
        }
      ]
    },
    {
      "id": "field-article-author",
      "name": "author",
      "typeName": "User",
      "nullable": false,
      "description": "Article author"
    },
    {
      "id": "field-article-tags",
      "name": "tags",
      "typeName": "String",
      "isList": true,
      "listItemNullable": false,
      "nullable": false,
      "description": "Categorisation tags"
    }
  ],
  "directives": [
    {
      "directiveId": "cacheControl",
      "arguments": {
        "maxAge": 3600
      }
    }
  ]
}

Related Content