52 / 89 · 04 API & Contract Testing with AI · Schema Federation Testing← prev⊞ allnext →☰ Read as one page
8.8AI-Generated Federation Tests
Ask AI to generate federation tests from your subgraph schemas:
Given the following Apollo Federation subgraph schemas, generate tests
that verify correct composition:
Subgraph 1 (ProductService):
type Product @key(fields: "id") {
id: ID!
name: String!
price: Float!
category: Category!
}
Subgraph 2 (InventoryService):
extend type Product @key(fields: "id") {
id: ID! @external
inStock: Boolean!
warehouseLocation: String
}
Subgraph 3 (ReviewService):
extend type Product @key(fields: "id") {
id: ID! @external
reviews: [Review!]!
averageRating: Float
}
Generate tests for:
1. Each subgraph's fields resolve correctly through the gateway
2. Cross-subgraph queries work (e.g., product with stock AND reviews)
3. Entity reference resolution (no null references)
4. Performance: cross-subgraph queries under 2s
5. Error handling: what happens when one subgraph is down?