50 / 89 · 04 API & Contract Testing with AI · Schema Federation Testing← prev⊞ allnext →☰ Read as one page
8.6Test 4: Subgraph Health and Availability
def test_all_subgraphs_healthy(self, subgraph_endpoints):
"""Each subgraph should respond to health checks."""
for name, url in subgraph_endpoints.items():
response = httpx.get(f"{url}/.well-known/apollo/server-health")
assert response.status_code == 200, (
f"Subgraph '{name}' at {url} is unhealthy: {response.status_code}"
)
def test_gateway_introspection(self, gateway_client):
"""Gateway should respond to introspection queries."""
query = """
{
__schema {
types { name }
queryType { name }
}
}
"""
response = gateway_client.execute(query)
assert "errors" not in response
type_names = [t["name"] for t in response["data"]["__schema"]["types"]]
# Verify key types from each subgraph are present
assert "Product" in type_names
assert "Order" in type_names
assert "User" in type_names