Skip to content

Commit 6f4861a

Browse files
Add bits to federated seed schema (#7288)
1 parent 791c025 commit 6f4861a

File tree

5 files changed

+461
-16
lines changed

5 files changed

+461
-16
lines changed

scripts/seed-schemas/federated/inventory.graphql

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,45 @@ extend schema
44
import: ["@key", "@shareable", "@external", "@requires"]
55
)
66

7-
type Product @key(fields: "upc dimensions") {
7+
extend type Product @key(fields: "upc dimensions") {
8+
"""
9+
Universal Product Code
10+
"""
811
upc: String!
12+
"""
13+
Physical dimensions (from products subgraph)
14+
"""
915
dimensions: ProductDimension @external
16+
"""
17+
Delivery estimates for a given zip code (requires dimensions data)
18+
"""
1019
delivery(zip: String): DeliveryEstimates @requires(fields: "dimensions { size weight }")
1120
}
1221

22+
"""
23+
Physical dimensions of a product (shared across subgraphs)
24+
"""
1325
type ProductDimension @shareable {
26+
"""
27+
Size description (e.g., 'Small', 'Large', '10x5x3')
28+
"""
1429
size: String
30+
"""
31+
Weight in pounds
32+
"""
1533
weight: Float
1634
}
1735

36+
"""
37+
Delivery time estimates for a product
38+
"""
1839
type DeliveryEstimates {
40+
"""
41+
Estimated standard delivery date
42+
"""
1943
estimatedDelivery: String
44+
"""
45+
Fastest possible delivery date
46+
"""
2047
fastestDelivery: String
2148
}
22-
23-
enum ShippingClass {
24-
STANDARD
25-
EXPRESS
26-
OVERNIGHT
27-
}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
extend schema @link(url: "https://specs.apollo.dev/federation/v2.3", import: ["@key", "@external"])
2+
3+
"""
4+
ISO-8601 formatted date and time string
5+
"""
6+
scalar DateTime
7+
8+
"""
9+
Types of notifications that can be sent to users
10+
"""
11+
enum NotificationType {
12+
"""
13+
Notification about a product update
14+
"""
15+
PRODUCT_UPDATE
16+
"""
17+
Notification when a new review is posted
18+
"""
19+
REVIEW_POSTED
20+
"""
21+
Welcome notification for new users
22+
"""
23+
WELCOME
24+
}
25+
26+
"""
27+
Filter criteria for searching notifications
28+
"""
29+
input NotificationFilterInput {
30+
"""
31+
Search text to match against notification messages
32+
"""
33+
searchText: String
34+
"""
35+
Filter by specific notification types
36+
"""
37+
types: [NotificationType!]
38+
"""
39+
Only include notifications from this date onwards
40+
"""
41+
dateFrom: DateTime
42+
"""
43+
Only include notifications up to this date
44+
"""
45+
dateTo: DateTime
46+
}
47+
48+
"""
49+
Base interface for all notification types
50+
"""
51+
interface NotificationItf {
52+
id: ID!
53+
message: String!
54+
}
55+
56+
"""
57+
Notification sent when a product is updated
58+
"""
59+
type ProductUpdateNotification implements NotificationItf {
60+
"""
61+
Unique identifier for the notification
62+
"""
63+
id: ID!
64+
"""
65+
Human-readable notification message
66+
"""
67+
message: String!
68+
"""
69+
The product that was updated
70+
"""
71+
product: Product!
72+
"""
73+
Timestamp when the product was updated
74+
"""
75+
updatedAt: DateTime!
76+
}
77+
78+
"""
79+
Notification sent when a review is posted
80+
"""
81+
type ReviewPostedNotification implements NotificationItf {
82+
"""
83+
Unique identifier for the notification
84+
"""
85+
id: ID!
86+
"""
87+
Human-readable notification message
88+
"""
89+
message: String!
90+
"""
91+
The review that was posted
92+
"""
93+
review: Review!
94+
"""
95+
Timestamp when the review was posted
96+
"""
97+
postedAt: DateTime!
98+
}
99+
100+
"""
101+
Welcome notification sent to new users
102+
"""
103+
type WelcomeNotification implements NotificationItf {
104+
"""
105+
Unique identifier for the notification
106+
"""
107+
id: ID!
108+
"""
109+
Human-readable notification message
110+
"""
111+
message: String!
112+
"""
113+
Timestamp when the notification was created
114+
"""
115+
createdAt: DateTime!
116+
}
117+
118+
"""
119+
Union of all possible notification types
120+
"""
121+
union Notification = ProductUpdateNotification | ReviewPostedNotification | WelcomeNotification
122+
123+
extend type User @key(fields: "id") {
124+
"""
125+
Unique identifier for the user
126+
"""
127+
id: ID! @external
128+
"""
129+
List of all notifications for this user
130+
"""
131+
notifications: [Notification!]!
132+
}
133+
134+
extend type Product @key(fields: "upc") {
135+
"""
136+
Universal Product Code
137+
"""
138+
upc: String!
139+
}
140+
141+
"""
142+
Review stub reference (full definition in reviews subgraph)
143+
"""
144+
type Review @key(fields: "id") {
145+
"""
146+
Unique identifier for the review
147+
"""
148+
id: ID!
149+
}
150+
151+
extend type Query {
152+
notification(id: ID!): Notification
153+
notifications: [Notification!]!
154+
searchNotifications(filter: NotificationFilterInput!): [Notification!]!
155+
}

0 commit comments

Comments
 (0)