Skip to content

Commit

Permalink
extract ftv1 to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
cappuc committed Dec 1, 2023
1 parent a77e030 commit 4eeab05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/Tracing/FederatedTracing/FederatedTracing.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class FederatedTracing implements Tracing

public const NAME = 'federated-tracing';

public const V1 = 'ftv1';

protected bool $isSubgraph;

protected bool $enabled = true;
Expand All @@ -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;
Expand Down Expand Up @@ -103,7 +105,7 @@ public function handleBuildExtensionsResponse(BuildExtensionsResponse $buildExte
assert($this->trace !== null);

return new ExtensionsResponse(
'ftv1',
self::V1,
base64_encode($this->trace->serializeToString()),
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Tracing/FederatedTracingExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4eeab05

Please sign in to comment.