-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
424 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
namespace Enjin\Platform\Beam\GraphQL\Queries; | ||
|
||
use Closure; | ||
use Enjin\Platform\Beam\Models\BeamClaim; | ||
use Enjin\Platform\GraphQL\Types\Pagination\ConnectionInput; | ||
use Enjin\Platform\Interfaces\PlatformPublicGraphQlOperation; | ||
use Enjin\Platform\Rules\ValidSubstrateAccount; | ||
use Enjin\Platform\Support\SS58Address; | ||
use GraphQL\Type\Definition\ResolveInfo; | ||
use GraphQL\Type\Definition\Type; | ||
use Illuminate\Support\Arr; | ||
use Rebing\GraphQL\Support\Facades\GraphQL; | ||
|
||
class GetPendingClaimsQuery extends Query implements PlatformPublicGraphQlOperation | ||
{ | ||
/** | ||
* Get the query's attributes. | ||
*/ | ||
public function attributes(): array | ||
{ | ||
return [ | ||
'name' => 'GetPendingClaims', | ||
'description' => __('enjin-platform-beam::query.get_pending_claims.description'), | ||
]; | ||
} | ||
|
||
/** | ||
* Get the query's return type. | ||
*/ | ||
public function type(): Type | ||
{ | ||
return GraphQL::paginate('BeamClaim', 'BeamClaimConnection'); | ||
} | ||
|
||
/** | ||
* Get the query's arguments definition. | ||
*/ | ||
public function args(): array | ||
{ | ||
return ConnectionInput::args([ | ||
'code' => [ | ||
'type' => GraphQL::type('String!'), | ||
'description' => __('enjin-platform-beam::mutation.claim_beam.args.code'), | ||
], | ||
'account' => [ | ||
'type' => GraphQL::type('String!'), | ||
'description' => __('enjin-platform-beam::mutation.claim_beam.args.account'), | ||
], | ||
]); | ||
} | ||
|
||
/** | ||
* Resolve the query's request. | ||
*/ | ||
public function resolve( | ||
$root, | ||
array $args, | ||
$context, | ||
ResolveInfo $resolveInfo, | ||
Closure $getSelectFields | ||
) { | ||
return BeamClaim::loadSelectFields($resolveInfo, $this->name) | ||
->hasCode(Arr::get($args, 'code')) | ||
->where('wallet_public_key', SS58Address::getPublicKey(Arr::get($args, 'account'))) | ||
->cursorPaginateWithTotalDesc('id', $args['first']); | ||
} | ||
|
||
/** | ||
* Get the query's request validation rules. | ||
*/ | ||
protected function rules(array $args = []): array | ||
{ | ||
return [ | ||
'code' => ['filled', 'max:1024'], | ||
'account' => ['filled', new ValidSubstrateAccount()], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.