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