Skip to content

Commit

Permalink
test that rules are applied on relay mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissm79 committed Jun 2, 2016
1 parent 81c7946 commit e36f6d4
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/Queries/MutationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Nuwave\Lighthouse\Tests\Support\GraphQL\Types\TaskType;
use Nuwave\Lighthouse\Tests\Support\GraphQL\Mutations\UpdateEmailMutation;
use Nuwave\Lighthouse\Tests\Support\GraphQL\Mutations\UpdateEmailRelayMutation;
use Illuminate\Support\MessageBag;

class MutationTest extends TestCase
{
Expand Down Expand Up @@ -40,7 +41,6 @@ public function itCanResolveMutation()

/**
* @test
* @group failing
*/
public function itCanResolveRelayMutation()
{
Expand Down Expand Up @@ -79,4 +79,40 @@ public function itCanResolveRelayMutation()

$this->assertEquals(['data' => $expected], $this->executeQuery($query, $variables));
}

/**
* @test
*/
public function itAppliesRulesToArgs()
{
$id = $this->encodeGlobalId(UserType::class, 'foo');

$query = 'mutation UpdateUserEmailRelay($input: UpdateUserPasswordRelayInput!) {
updateEmail(input: $input) {
user {
email
}
clientMutationId
}
}';

$variables = [
'input' => [
'id' => $id,
'email' => 'foo',
'clientMutationId' => 'abcde'
]
];

$graphql = app('graphql');
$graphql->schema()->type('user', UserType::class);
$graphql->schema()->type('task', TaskType::class);
$graphql->schema()->mutation('updateEmail', UpdateEmailRelayMutation::class);

$data = $this->executeQuery($query, $variables);
$errors = array_get($data, 'errors.0.validation');

$this->assertInstanceOf(MessageBag::class, $errors);
$this->assertContains('email', $errors->keys());
}
}

0 comments on commit e36f6d4

Please sign in to comment.