Skip to content

Commit

Permalink
Fix finding the operation definition node on the query
Browse files Browse the repository at this point in the history
  • Loading branch information
stayallive committed Apr 12, 2024
1 parent 054e0d6 commit b2e85b3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,9 @@ public function handleStartExecution(StartExecution $startExecution): void
return;
}

/** @var \GraphQL\Language\AST\OperationDefinitionNode|null $operationDefinition */
$operationDefinition = $startExecution->query->definitions[0] ?? null;
$operationDefinition = $this->extractOperationDefinitionNode($startExecution->query);

if (!$operationDefinition instanceof OperationDefinitionNode) {
if ($operationDefinition === null) {
return;
}

Expand Down Expand Up @@ -239,6 +238,17 @@ private function extractOperationNames(OperationDefinitionNode $operation): arra
return $selectionSet;
}

private function extractOperationDefinitionNode(DocumentNode $query): ?OperationDefinitionNode

Check failure on line 241 in src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method Sentry\Laravel\Tracing\Integrations\LighthouseIntegration::extractOperationDefinitionNode() has invalid return type GraphQL\Language\AST\OperationDefinitionNode.

Check failure on line 241 in src/Sentry/Laravel/Tracing/Integrations/LighthouseIntegration.php

View workflow job for this annotation

GitHub Actions / PHPStan

Parameter $query of method Sentry\Laravel\Tracing\Integrations\LighthouseIntegration::extractOperationDefinitionNode() has invalid type GraphQL\Language\AST\DocumentNode.
{
foreach ($query->definitions as $definition) {
if ($definition instanceof OperationDefinitionNode) {
return $definition;
}
}

return null;
}

private function isApplicable(): bool
{
if (!class_exists(StartRequest::class) || !class_exists(StartExecution::class)) {
Expand Down

0 comments on commit b2e85b3

Please sign in to comment.