From 4d302c9d8a0d0b7fbcd398093712c212c2d64fd9 Mon Sep 17 00:00:00 2001 From: Jonathan Brennan Date: Fri, 21 Nov 2025 12:08:56 -0600 Subject: [PATCH] add example metadata to subgraphs (#7300) --- .../seed-schemas/federated/inventory.graphql | 14 ++++++++++++-- .../federated/notifications.graphql | 13 +++++++++++-- .../seed-schemas/federated/products.graphql | 18 +++++++++++++----- .../seed-schemas/federated/reviews.graphql | 14 +++++++++++--- scripts/seed-schemas/federated/users.graphql | 19 ++++++++++++++++--- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/scripts/seed-schemas/federated/inventory.graphql b/scripts/seed-schemas/federated/inventory.graphql index 5bf6fc560..bd66468a9 100644 --- a/scripts/seed-schemas/federated/inventory.graphql +++ b/scripts/seed-schemas/federated/inventory.graphql @@ -3,6 +3,14 @@ extend schema url: "https://specs.apollo.dev/federation/v2.3" import: ["@key", "@shareable", "@external", "@requires"] ) + @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) + @meta(name: "owner", content: "inventory-team") + @meta(name: "contact", content: "#inventory-channel") + +directive @meta( + name: String! + content: String! +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION extend type Product @key(fields: "upc dimensions") { """ @@ -16,7 +24,9 @@ extend type Product @key(fields: "upc dimensions") { """ Delivery estimates for a given zip code (requires dimensions data) """ - delivery(zip: String): DeliveryEstimates @requires(fields: "dimensions { size weight }") + delivery(zip: String): DeliveryEstimates + @requires(fields: "dimensions { size weight }") + @meta(name: "priority", content: "tier2") } """ @@ -36,7 +46,7 @@ type ProductDimension @shareable { """ Delivery time estimates for a product """ -type DeliveryEstimates { +type DeliveryEstimates @meta(name: "domain", content: "inventory") { """ Estimated standard delivery date """ diff --git a/scripts/seed-schemas/federated/notifications.graphql b/scripts/seed-schemas/federated/notifications.graphql index 4c527b00d..953aae4fe 100644 --- a/scripts/seed-schemas/federated/notifications.graphql +++ b/scripts/seed-schemas/federated/notifications.graphql @@ -1,4 +1,13 @@ -extend schema @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external"]) +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external"]) + @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) + @meta(name: "owner", content: "notifications-team") + @meta(name: "contact", content: "#notifications-channel") + +directive @meta( + name: String! + content: String! +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION """ ISO-8601 formatted date and time string @@ -48,7 +57,7 @@ input NotificationFilterInput { """ Base interface for all notification types """ -interface NotificationItf { +interface NotificationItf @meta(name: "domain", content: "notifications") { id: ID! message: String! } diff --git a/scripts/seed-schemas/federated/products.graphql b/scripts/seed-schemas/federated/products.graphql index d49b82846..aeb697ffe 100644 --- a/scripts/seed-schemas/federated/products.graphql +++ b/scripts/seed-schemas/federated/products.graphql @@ -3,13 +3,21 @@ extend schema url: "https://specs.apollo.dev/federation/v2.3" import: ["@key", "@shareable", "@inaccessible", "@tag", "@external"] ) + @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) + @meta(name: "owner", content: "products-team") + @meta(name: "contact", content: "#products-channel") directive @example(text: String!) on FIELD_DEFINITION +directive @meta( + name: String! + content: String! +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION + """ Product interface defining common product fields """ -interface ProductItf implements SkuItf { +interface ProductItf implements SkuItf @meta(name: "domain", content: "products") { upc: String! sku: String name: String @@ -57,7 +65,7 @@ The **Product** type represents physical or _digital items_ available in the cat *Related types: `ProductItf`, `ProductDimension`, `ShippingClass`* """ -type Product implements ProductItf & SkuItf @key(fields: "upc") @key(fields: "sku package") { +type Product implements ProductItf & SkuItf { """ Universal Product Code. A standardized numeric global identifier """ @@ -65,7 +73,7 @@ type Product implements ProductItf & SkuItf @key(fields: "upc") @key(fields: "sk """ SKUs are unique to the company and are used internally. Alphanumeric. """ - sku: String @tag(name: "internal") + sku: String @tag(name: "internal") @meta(name: "sensitivity", content: "internal") """ Product name """ @@ -93,7 +101,7 @@ type Product implements ProductItf & SkuItf @key(fields: "upc") @key(fields: "sk """ Aggregated review score for this product """ - reviewsScore: Float! + reviewsScore: Float! @meta(name: "category", content: "analytics") """ Deprecated field that has been refactored out """ @@ -183,7 +191,7 @@ type Query { """ Get all products in the catalog """ - allProducts: [ProductItf!]! + allProducts: [ProductItf!]! @meta(name: "priority", content: "tier1") """ Get a specific product by its UPC """ diff --git a/scripts/seed-schemas/federated/reviews.graphql b/scripts/seed-schemas/federated/reviews.graphql index 2cd27a425..9657ec899 100644 --- a/scripts/seed-schemas/federated/reviews.graphql +++ b/scripts/seed-schemas/federated/reviews.graphql @@ -3,6 +3,14 @@ extend schema url: "https://specs.apollo.dev/federation/v2.3" import: ["@key", "@override", "@external", "@provides"] ) + @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) + @meta(name: "owner", content: "reviews-team") + @meta(name: "contact", content: "#reviews-channel") + +directive @meta( + name: String! + content: String! +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION """ Input for creating a new product review @@ -25,7 +33,7 @@ input CreateReviewInput { """ Product review written by a user """ -type Review @key(fields: "id") { +type Review @key(fields: "id") @meta(name: "domain", content: "reviews") { """ Unique identifier for the review """ @@ -52,8 +60,8 @@ extend type User @key(fields: "id") { extend type Product @key(fields: "upc") { upc: String! reviews: [Review] - reviewsCount: Int! - reviewsScore: Float! @override(from: "products") + reviewsCount: Int! @meta(name: "category", content: "analytics") + reviewsScore: Float! @override(from: "products") @meta(name: "category", content: "analytics") } type Query { diff --git a/scripts/seed-schemas/federated/users.graphql b/scripts/seed-schemas/federated/users.graphql index f1b006bc8..7a71de627 100644 --- a/scripts/seed-schemas/federated/users.graphql +++ b/scripts/seed-schemas/federated/users.graphql @@ -1,7 +1,16 @@ extend schema @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@tag", "@shareable"]) + @link(url: "https://specs.graphql-hive.com/hive/v1.0", import: ["@meta"]) + @meta(name: "owner", content: "users-team") + @meta(name: "contact", content: "#users-channel") + directive @tag(name: String!) repeatable on FIELD_DEFINITION | OBJECT +directive @meta( + name: String! + content: String! +) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION + """ ## User Account @@ -17,7 +26,11 @@ Represents a **registered user** in the system. User data is subject to *strict **Authentication**: Users authenticate via email or username **Federation**: Extended by other subgraphs for additional user data """ -type User @key(fields: "id") @key(fields: "email") { +type User + @key(fields: "id") + @key(fields: "email") + @meta(name: "domain", content: "users") + @meta(name: "priority", content: "tier1") { """ Unique identifier for the user """ @@ -25,11 +38,11 @@ type User @key(fields: "id") @key(fields: "email") { """ User's email address (tagged as PII for data privacy compliance) """ - email: String! @tag(name: "pii") + email: String! @tag(name: "pii") @meta(name: "sensitivity", content: "pii") """ User's full name """ - name: String + name: String @meta(name: "sensitivity", content: "pii") """ User's display alias or username """