add example metadata to subgraphs (#7300)

This commit is contained in:
Jonathan Brennan 2025-11-21 12:08:56 -06:00 committed by GitHub
parent 8e01207ac6
commit 4d302c9d8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 63 additions and 15 deletions

View file

@ -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
"""

View file

@ -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!
}

View file

@ -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
"""

View file

@ -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 {

View file

@ -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
"""