Skip to Content

Subgraph Metadata Features

Jeff Dolle

What’s New?

  • Linkable @meta directive – A federation compatible, @link-able schema to add metadata and enhance functionality of your schema.

Feature Details

One of the most convincing reasons to use GraphQL that it’s self documenting. Hive takes this a step further by defining a convenient and type safe way to add key-value metadata to your schema. The @meta directive is the first directive we’ve added to a new Federation 2.x compatible set of Hive features. To opt-in, add a Federation link directive to your schema definition:

extend schema @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])

Metadata is useful for a variety of cases:

  • Indicating granular ownership e.g. owner: "console-team"
  • Adding contact information e.g. contact: "#hive-channel"
  • Defining field importance e.g. priority: "tier-1"
  • Defining domains e.g. domain: "users"

… and more.

Currently, metadata can be viewed from Hive’s explorer page and can be used to filter the explorer view. And we expect there will be even more features built around this metadata in the future as Hive continues to expand.

A full example schema of using metadata would look like:

extend schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/federation/v2.3") @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) @meta(name: "owner", content: "users-team") directive @meta( name: String! content: String! ) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION type Query { me: User @meta(name: "priority", content: "tier-1") } type User { id: ID! name: String! }

Learn more in the updated documentation

Last updated on