From c6162cf59c96db761727dfa91bb587ac890c8b5e Mon Sep 17 00:00:00 2001 From: William Allen Date: Tue, 10 Mar 2026 09:44:06 -0400 Subject: [PATCH] Add test output fields to GraphQL API This commit continues our ongoing effort to expose all CDash data via GraphQL. These new `path`, `command`, and `output` fields are not currently filterable because they are pulled from a separate relation. In the future, we can create a Postgres view which joins these relations and a corresponding model to allow these fields to be filtered. --- app/Models/Test.php | 31 ++++++++++++++++++++++++++ graphql/schema.graphql | 6 +++++ tests/Feature/GraphQL/TestTypeTest.php | 7 ++++++ 3 files changed, 44 insertions(+) diff --git a/app/Models/Test.php b/app/Models/Test.php index 9a8211a030..a89eb00a3c 100644 --- a/app/Models/Test.php +++ b/app/Models/Test.php @@ -6,6 +6,7 @@ use Carbon\Carbon; use CDash\Model\Label; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -131,6 +132,36 @@ public function testImages(): HasMany return $this->hasMany(TestImage::class, 'testid'); } + /** + * @return Attribute + */ + protected function path(): Attribute + { + return Attribute::make( + get: fn (mixed $value, array $attributes): ?string => $this->testOutput->path ?? null, + ); + } + + /** + * @return Attribute + */ + protected function command(): Attribute + { + return Attribute::make( + get: fn (mixed $value, array $attributes): ?string => $this->testOutput->command ?? null, + ); + } + + /** + * @return Attribute + */ + protected function output(): Attribute + { + return Attribute::make( + get: fn (mixed $value, array $attributes): ?string => $this->testOutput->output ?? null, + ); + } + /** * Add a label to this buildtest. * diff --git a/graphql/schema.graphql b/graphql/schema.graphql index 125c76471d..a67bd25860 100644 --- a/graphql/schema.graphql +++ b/graphql/schema.graphql @@ -889,6 +889,12 @@ type Test { details: String! @filterable + path: String @with(relation: "testOutput") + + command: String @with(relation: "testOutput") + + output: String @with(relation: "testOutput") + testMeasurements( filters: _ @filter ): [TestMeasurement!]! @hasMany @orderBy(column: "id", direction: DESC) diff --git a/tests/Feature/GraphQL/TestTypeTest.php b/tests/Feature/GraphQL/TestTypeTest.php index cbfbedbc98..90753eaf0a 100644 --- a/tests/Feature/GraphQL/TestTypeTest.php +++ b/tests/Feature/GraphQL/TestTypeTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\GraphQL; use App\Models\Project; +use App\Models\Test; use App\Models\TestOutput; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Str; @@ -80,6 +81,9 @@ public function testBasicFieldAccess(): void details runningTime startTime + path + command + output } } } @@ -107,6 +111,9 @@ public function testBasicFieldAccess(): void 'details' => 'details text', 'runningTime' => 1.2, 'startTime' => '2026-02-13T18:03:54+00:00', + 'path' => 'a', + 'command' => 'b', + 'output' => 'c', ], ], ],