Modern QA2026Test 5: Cross-Subgraph Query Performance — tiles
Log inJoin
51 / 89 · 04 API & Contract Testing with AI · Schema Federation Testing← prev⊞ allnext →☰ Read as one page

8.7Test 5: Cross-Subgraph Query Performance

    def test_cross_subgraph_query_latency(self, gateway_client):
        """Queries spanning multiple subgraphs should meet latency SLA."""
        # This query touches all three subgraphs
        query = """
        query {
          user(id: "user-1") {
            name                          # UserService
            orders(first: 5) {            # OrderService
              id
              total
              items {
                product {
                  name                    # ProductService
                  price
                }
              }
            }
          }
        }
        """
        import time
        start = time.monotonic()
        response = gateway_client.execute(query)
        duration = time.monotonic() - start

        assert "errors" not in response
        assert duration < 3.0, (
            f"Cross-subgraph query took {duration:.2f}s, SLA is 3.0s. "
            f"Check query plan and subgraph latencies."
        )