Skip to content

Commit 4f307b9

Browse files
authored
docs: add hive link docs (#6569)
1 parent e10de03 commit 4f307b9

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

packages/libraries/federation-link-utils/src/link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class FederatedLink {
130130
/**
131131
* Given the name of an element in a linked schema, this returns the name of that element
132132
* as it has been imported. This accounts for aliasing and namespacing unreferenced imports.
133-
* This can be used by LinkSpecs to get the translated names of elements.
133+
* This can be used within implementations to reference the translated names of elements.
134134
*
135135
* The directive `@` prefix is removed from the returned name. This is to make it easier to match node names when visiting a schema definition.
136136
* When visiting nodes, a directive's name doesn't include the `@`.
232 KB
Loading
216 KB
Loading
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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

Comments
 (0)