Skip to content

Commit

Permalink
[PLA-1891] Hide sensitive attributes from beam APIs (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner authored and leonardocustodio committed Jul 15, 2024
1 parent 6a391d9 commit d7d6963
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/GraphQL/Queries/GetBeamsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
use Enjin\Platform\Beam\Services\BeamService;
use Enjin\Platform\GraphQL\Middleware\ResolvePage;
use Enjin\Platform\GraphQL\Types\Pagination\ConnectionInput;
use Enjin\Platform\Interfaces\PlatformPublicGraphQlOperation;
use GraphQL\Type\Definition\ResolveInfo;
use GraphQL\Type\Definition\Type;
use Illuminate\Support\Arr;
use Rebing\GraphQL\Support\Facades\GraphQL;

class GetBeamsQuery extends Query implements PlatformPublicGraphQlOperation
class GetBeamsQuery extends Query
{
use HasBeamCommonFields;

Expand Down
4 changes: 4 additions & 0 deletions src/GraphQL/Types/BeamType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Enjin\Platform\Beam\GraphQL\Traits\HasBeamCommonFields;
use Enjin\Platform\Beam\Models\Beam;
use Enjin\Platform\Beam\Services\BeamService;
use Enjin\Platform\GraphQL\Schemas\Traits\HasAuthorizableFields;
use Enjin\Platform\GraphQL\Types\Pagination\ConnectionInput;
use Enjin\Platform\Traits\HasSelectFields;
use Illuminate\Pagination\Cursor;
Expand All @@ -17,6 +18,7 @@

class BeamType extends Type
{
use HasAuthorizableFields;
use HasBeamCommonFields;
use HasSelectFields;

Expand Down Expand Up @@ -45,6 +47,7 @@ public function fields(): array
'code' => [
'type' => GraphQL::type('String!'),
'description' => __('enjin-platform-beam::mutation.claim_beam.args.code'),
'excludeFrom' => ['GetBeam', 'GetBeams'],
],
...$this->getCommonFields(),
'collection' => [
Expand Down Expand Up @@ -89,6 +92,7 @@ public function fields(): array
},
'selectable' => false,
'is_relation' => false,
'excludeFrom' => ['GetBeam', 'GetBeams'],
],
'probabilities' => [
'type' => GraphQL::type('Object'),
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/GraphQL/Queries/GetBeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function test_it_hides_code_field_when_unauthenticated()
]);

$response = $this->graphql($this->method, ['code' => $this->beam->code], true);
$this->assertEquals('Cannot query field "code" on type "BeamClaim".', $response['error']);
$this->assertEquals('Cannot query field "code" on type "Beam".', $response['error']);

config([
'enjin-platform.auth' => null,
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/GraphQL/Queries/GetBeamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function test_it_hides_code_field_when_unauthenticated()
]);

$response = $this->graphql($this->method, [], true);
$this->assertEquals('Cannot query field "code" on type "BeamClaim".', $response['error']);
$this->assertEquals('Cannot query field "code" on type "Beam".', $response['error']);

config([
'enjin-platform.auth' => null,
Expand Down

0 comments on commit d7d6963

Please sign in to comment.