Skip to content

Commit 4d302c9

Browse files
add example metadata to subgraphs (#7300)
1 parent 8e01207 commit 4d302c9

File tree

5 files changed

+63
-15
lines changed

5 files changed

+63
-15
lines changed

scripts/seed-schemas/federated/inventory.graphql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ extend schema
33
url: "https://specs.apollo.dev/federation/v2.3"
44
import: ["@key", "@shareable", "@external", "@requires"]
55
)
6+
@link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])
7+
@meta(name: "owner", content: "inventory-team")
8+
@meta(name: "contact", content: "#inventory-channel")
9+
10+
directive @meta(
11+
name: String!
12+
content: String!
13+
) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
614

715
extend type Product @key(fields: "upc dimensions") {
816
"""
@@ -16,7 +24,9 @@ extend type Product @key(fields: "upc dimensions") {
1624
"""
1725
Delivery estimates for a given zip code (requires dimensions data)
1826
"""
19-
delivery(zip: String): DeliveryEstimates @requires(fields: "dimensions { size weight }")
27+
delivery(zip: String): DeliveryEstimates
28+
@requires(fields: "dimensions { size weight }")
29+
@meta(name: "priority", content: "tier2")
2030
}
2131

2232
"""
@@ -36,7 +46,7 @@ type ProductDimension @shareable {
3646
"""
3747
Delivery time estimates for a product
3848
"""
39-
type DeliveryEstimates {
49+
type DeliveryEstimates @meta(name: "domain", content: "inventory") {
4050
"""
4151
Estimated standard delivery date
4252
"""

scripts/seed-schemas/federated/notifications.graphql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
extend schema @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external"])
1+
extend schema
2+
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external"])
3+
@link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])
4+
@meta(name: "owner", content: "notifications-team")
5+
@meta(name: "contact", content: "#notifications-channel")
6+
7+
directive @meta(
8+
name: String!
9+
content: String!
10+
) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
211

312
"""
413
ISO-8601 formatted date and time string
@@ -48,7 +57,7 @@ input NotificationFilterInput {
4857
"""
4958
Base interface for all notification types
5059
"""
51-
interface NotificationItf {
60+
interface NotificationItf @meta(name: "domain", content: "notifications") {
5261
id: ID!
5362
message: String!
5463
}

scripts/seed-schemas/federated/products.graphql

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ extend schema
33
url: "https://specs.apollo.dev/federation/v2.3"
44
import: ["@key", "@shareable", "@inaccessible", "@tag", "@external"]
55
)
6+
@link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])
7+
@meta(name: "owner", content: "products-team")
8+
@meta(name: "contact", content: "#products-channel")
69

710
directive @example(text: String!) on FIELD_DEFINITION
811

12+
directive @meta(
13+
name: String!
14+
content: String!
15+
) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
16+
917
"""
1018
Product interface defining common product fields
1119
"""
12-
interface ProductItf implements SkuItf {
20+
interface ProductItf implements SkuItf @meta(name: "domain", content: "products") {
1321
upc: String!
1422
sku: String
1523
name: String
@@ -57,15 +65,15 @@ The **Product** type represents physical or _digital items_ available in the cat
5765
5866
*Related types: `ProductItf`, `ProductDimension`, `ShippingClass`*
5967
"""
60-
type Product implements ProductItf & SkuItf @key(fields: "upc") @key(fields: "sku package") {
68+
type Product implements ProductItf & SkuItf {
6169
"""
6270
Universal Product Code. A standardized numeric global identifier
6371
"""
6472
upc: String!
6573
"""
6674
SKUs are unique to the company and are used internally. Alphanumeric.
6775
"""
68-
sku: String @tag(name: "internal")
76+
sku: String @tag(name: "internal") @meta(name: "sensitivity", content: "internal")
6977
"""
7078
Product name
7179
"""
@@ -93,7 +101,7 @@ type Product implements ProductItf & SkuItf @key(fields: "upc") @key(fields: "sk
93101
"""
94102
Aggregated review score for this product
95103
"""
96-
reviewsScore: Float!
104+
reviewsScore: Float! @meta(name: "category", content: "analytics")
97105
"""
98106
Deprecated field that has been refactored out
99107
"""
@@ -183,7 +191,7 @@ type Query {
183191
"""
184192
Get all products in the catalog
185193
"""
186-
allProducts: [ProductItf!]!
194+
allProducts: [ProductItf!]! @meta(name: "priority", content: "tier1")
187195
"""
188196
Get a specific product by its UPC
189197
"""

scripts/seed-schemas/federated/reviews.graphql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ extend schema
33
url: "https://specs.apollo.dev/federation/v2.3"
44
import: ["@key", "@override", "@external", "@provides"]
55
)
6+
@link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])
7+
@meta(name: "owner", content: "reviews-team")
8+
@meta(name: "contact", content: "#reviews-channel")
9+
10+
directive @meta(
11+
name: String!
12+
content: String!
13+
) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
614

715
"""
816
Input for creating a new product review
@@ -25,7 +33,7 @@ input CreateReviewInput {
2533
"""
2634
Product review written by a user
2735
"""
28-
type Review @key(fields: "id") {
36+
type Review @key(fields: "id") @meta(name: "domain", content: "reviews") {
2937
"""
3038
Unique identifier for the review
3139
"""
@@ -52,8 +60,8 @@ extend type User @key(fields: "id") {
5260
extend type Product @key(fields: "upc") {
5361
upc: String!
5462
reviews: [Review]
55-
reviewsCount: Int!
56-
reviewsScore: Float! @override(from: "products")
63+
reviewsCount: Int! @meta(name: "category", content: "analytics")
64+
reviewsScore: Float! @override(from: "products") @meta(name: "category", content: "analytics")
5765
}
5866

5967
type Query {

scripts/seed-schemas/federated/users.graphql

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
extend schema
22
@link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@tag", "@shareable"])
3+
@link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"])
4+
@meta(name: "owner", content: "users-team")
5+
@meta(name: "contact", content: "#users-channel")
6+
37
directive @tag(name: String!) repeatable on FIELD_DEFINITION | OBJECT
48

9+
directive @meta(
10+
name: String!
11+
content: String!
12+
) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
13+
514
"""
615
## User Account
716
@@ -17,19 +26,23 @@ Represents a **registered user** in the system. User data is subject to *strict
1726
**Authentication**: Users authenticate via email or username
1827
**Federation**: Extended by other subgraphs for additional user data
1928
"""
20-
type User @key(fields: "id") @key(fields: "email") {
29+
type User
30+
@key(fields: "id")
31+
@key(fields: "email")
32+
@meta(name: "domain", content: "users")
33+
@meta(name: "priority", content: "tier1") {
2134
"""
2235
Unique identifier for the user
2336
"""
2437
id: ID!
2538
"""
2639
User's email address (tagged as PII for data privacy compliance)
2740
"""
28-
email: String! @tag(name: "pii")
41+
email: String! @tag(name: "pii") @meta(name: "sensitivity", content: "pii")
2942
"""
3043
User's full name
3144
"""
32-
name: String
45+
name: String @meta(name: "sensitivity", content: "pii")
3346
"""
3447
User's display alias or username
3548
"""

0 commit comments

Comments
 (0)