Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Support/OperationParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected function init(BaseOperationParams $baseOperationParams): void
$this->operation = $baseOperationParams->operation;
$this->variables = $baseOperationParams->variables;
$this->extensions = $baseOperationParams->extensions;
$this->originalInput = $baseOperationParams->originalInput ?? [];

$this->baseOperationParams = $baseOperationParams;
}
Expand Down
27 changes: 27 additions & 0 deletions tests/Unit/ExecutionMiddlewareTest/ExecutionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Illuminate\Auth\GenericUser;
use Rebing\GraphQL\Support\ExecutionMiddleware\AddAuthUserContextValueMiddleware;
use Rebing\GraphQL\Support\ExecutionMiddleware\ValidateOperationParamsMiddleware;
use Rebing\GraphQL\Tests\TestCase;

class ExecutionMiddlewareTest extends TestCase
Expand Down Expand Up @@ -171,4 +172,30 @@ public function testAddAuthUserContextValueMiddleware(): void
];
self::assertSame($expected, $result);
}

public function testValidateOperationParamsMiddlewareWithInvalidParams(): void
{
$this->app['config']->set('graphql.execution_middleware', [
ValidateOperationParamsMiddleware::class,
]);

$result = $this->httpGraphql($this->queries['examples'], [
'expectErrors' => true,
'variables' => [
[],
],
]);

$expected = [
'errors' => [
[
'message' => 'GraphQL Request parameter "variables" must be object or JSON string parsed to object, but got [[]]',
'extensions' => [
],
],
],
];

self::assertEquals($expected, $result);
}
}