Modern QA2026Graceful Degradation Testing — tiles
Log inJoin
53 / 89 · 04 API & Contract Testing with AI · Schema Federation Testing← prev⊞ allnext →☰ Read as one page

8.9Graceful Degradation Testing

    def test_gateway_handles_subgraph_failure(self, gateway_client, subgraph_controller):
        """Gateway should return partial data when one subgraph is down."""
        # Stop the ReviewService subgraph
        subgraph_controller.stop("ReviewService")

        query = """
        query {
          product(id: "prod-1") {
            name          # From ProductService (available)
            price         # From ProductService (available)
            reviews {     # From ReviewService (unavailable)
              rating
            }
          }
        }
        """
        response = gateway_client.execute(query)

        # Product data should still be available
        assert response["data"]["product"]["name"] is not None
        assert response["data"]["product"]["price"] is not None

        # Reviews should be null or have an error
        assert (
            response["data"]["product"]["reviews"] is None
            or "errors" in response
        )

        # Restart for other tests
        subgraph_controller.start("ReviewService")