From 4eeab055d9d5ca65191bc7602a12e5cc734c9c29 Mon Sep 17 00:00:00 2001 From: Fabio Capucci Date: Fri, 1 Dec 2023 10:38:02 +0100 Subject: [PATCH] extract ftv1 to a constant --- src/Tracing/FederatedTracing/FederatedTracing.php | 6 ++++-- tests/Integration/Tracing/FederatedTracingExtensionTest.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Tracing/FederatedTracing/FederatedTracing.php b/src/Tracing/FederatedTracing/FederatedTracing.php index 7a255e804..b9979ce38 100644 --- a/src/Tracing/FederatedTracing/FederatedTracing.php +++ b/src/Tracing/FederatedTracing/FederatedTracing.php @@ -27,6 +27,8 @@ class FederatedTracing implements Tracing public const NAME = 'federated-tracing'; + public const V1 = 'ftv1'; + protected bool $isSubgraph; protected bool $enabled = true; @@ -52,7 +54,7 @@ public function __construct() public function handleStartRequest(StartRequest $startRequest): void { - if ($this->isSubgraph && $startRequest->request->header('apollo-federation-include-trace') !== 'ftv1') { + if ($this->isSubgraph && $startRequest->request->header('apollo-federation-include-trace') !== self::V1) { $this->enabled = false; return; @@ -103,7 +105,7 @@ public function handleBuildExtensionsResponse(BuildExtensionsResponse $buildExte assert($this->trace !== null); return new ExtensionsResponse( - 'ftv1', + self::V1, base64_encode($this->trace->serializeToString()), ); } diff --git a/tests/Integration/Tracing/FederatedTracingExtensionTest.php b/tests/Integration/Tracing/FederatedTracingExtensionTest.php index 1fba4f180..ce40e46ce 100644 --- a/tests/Integration/Tracing/FederatedTracingExtensionTest.php +++ b/tests/Integration/Tracing/FederatedTracingExtensionTest.php @@ -54,7 +54,7 @@ public function testAddFtv1ExtensionMetaToResult(): void foo { id } } ', - headers: ['apollo-federation-include-trace' => 'ftv1'], + headers: ['apollo-federation-include-trace' => FederatedTracing::V1], ); $response->assertJsonStructure([ @@ -115,7 +115,7 @@ public function testAddFtv1ExtensionMetaToBatchedResults(): void $postData, $postData, ], - headers: ['apollo-federation-include-trace' => 'ftv1'], + headers: ['apollo-federation-include-trace' => FederatedTracing::V1], ); $result->assertJsonCount(2)