|
| 1 | +--- |
| 2 | +title: 'Hive Specifications: Federated Features' |
| 3 | +--- |
| 4 | + |
| 5 | +import NextImage from 'next/image' |
| 6 | +import { Tabs } from '@theguild/components' |
| 7 | + |
| 8 | +# GraphQL Hive Technical Specifications |
| 9 | + |
| 10 | +Federation `@link` compliant features for GraphQL Hive. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Introduction |
| 15 | + |
| 16 | +Links are a feature in Federation 2.x that allow external specifications to be referenced and used |
| 17 | +by a subgraph. Hive uses links to allow schemas to opt in to schema related features, such as |
| 18 | +metadata. |
| 19 | + |
| 20 | +### Importing via `@link` |
| 21 | + |
| 22 | +A preqrequisite is that the subgraph is using Federation 2.x: |
| 23 | + |
| 24 | +```graphql |
| 25 | +extend schema |
| 26 | + @link(url: "https://specs.apollo.dev/link/v1.0") |
| 27 | + @link(url: "https://specs.apollo.dev/federation/v2.3") |
| 28 | +``` |
| 29 | + |
| 30 | +Then the Hive features can be imported like: |
| 31 | + |
| 32 | +```graphql |
| 33 | +extend schema @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) |
| 34 | +``` |
| 35 | + |
| 36 | +Be sure to import and add definitions for all resources you intend to use. |
| 37 | + |
| 38 | +### Subgraph schema additions |
| 39 | + |
| 40 | +```graphql |
| 41 | +directive @meta( |
| 42 | + name: String! |
| 43 | + content: String! |
| 44 | +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION |
| 45 | +``` |
| 46 | + |
| 47 | +## Features |
| 48 | + |
| 49 | +### @meta |
| 50 | + |
| 51 | +<Tabs items={["v1.0"]}> |
| 52 | +<Tabs.Tab> |
| 53 | + |
| 54 | +Use this directive to enhance schema types with additional data, visible via the Hive Console. _This |
| 55 | +intentionally does not appear in the API Schema to avoid bloat. But if you want this directive to be |
| 56 | +returned to your gateway, then you can use `@composeDirective`_ |
| 57 | + |
| 58 | +```graphql |
| 59 | +directive @meta( |
| 60 | + name: String! |
| 61 | + content: String! |
| 62 | +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION |
| 63 | +``` |
| 64 | + |
| 65 | +Metadata is useful for indicating ownership, contact information, importance, domain, or more. It |
| 66 | +can be viewed from Hive's explorer page: |
| 67 | + |
| 68 | +import explorerMetadataViewImage from '../../../public/docs/pages/specs/link-specifications/explorer_metadata-view.png' |
| 69 | + |
| 70 | +<NextImage |
| 71 | + alt="Explorer with Metadata Visible" |
| 72 | + src={explorerMetadataViewImage} |
| 73 | + className="mt-10 max-w-2xl rounded-lg drop-shadow-md" |
| 74 | +/> |
| 75 | + |
| 76 | +And can be used in Hive's explorer page to filter the list of elements: |
| 77 | + |
| 78 | +import explorerMetadataFilterImage from '../../../public/docs/pages/specs/link-specifications/explorer_metadata-filter.png' |
| 79 | + |
| 80 | +<NextImage |
| 81 | + alt="Explorer with Metadata Filter" |
| 82 | + src={explorerMetadataFilterImage} |
| 83 | + className="mt-10 max-w-2xl rounded-lg drop-shadow-md" |
| 84 | +/> |
| 85 | + |
| 86 | +</Tabs.Tab> |
| 87 | +</Tabs> |
0 commit comments