From 081db968c57c378492ca0ec20601d48440643b84 Mon Sep 17 00:00:00 2001 From: Abner Tudtud <114082473+enjinabner@users.noreply.github.com> Date: Thu, 16 Nov 2023 09:36:14 +0800 Subject: [PATCH] Add Attributes Field to BeamClaimType (#46) --- lang/en/type.php | 1 + src/GraphQL/Types/AttributeType.php | 36 +++++++++++++++++++ src/GraphQL/Types/BeamClaimType.php | 4 +++ .../GraphQL/Resources/GetClaims.graphql | 4 +++ 4 files changed, 45 insertions(+) create mode 100644 src/GraphQL/Types/AttributeType.php diff --git a/lang/en/type.php b/lang/en/type.php index 57cde7b..ba90731 100644 --- a/lang/en/type.php +++ b/lang/en/type.php @@ -28,4 +28,5 @@ 'beam_scan.field.message' => 'The message to sign.', 'beam_scan.field.walletPublicKey' => 'The wallet public key.', 'integer_range.description' => "A string value that can be used to represent a range of integer numbers. Use a double full stop to supply a range between 2 integers. \n\nExample \[\"1\",\"2\",\"3..8\"\]", + 'attribute.description' => 'An initial attribute to set for the token when minting on demand.', ]; diff --git a/src/GraphQL/Types/AttributeType.php b/src/GraphQL/Types/AttributeType.php new file mode 100644 index 0000000..057d7df --- /dev/null +++ b/src/GraphQL/Types/AttributeType.php @@ -0,0 +1,36 @@ + 'AttributeType', + 'description' => __('enjin-platform-beam::type.attribute.description'), + ]; + } + + /** + * Get the type's fields definition. + */ + public function fields(): array + { + return [ + 'key' => [ + 'type' => GraphQL::type('String'), + 'description' => __('enjin-platform::mutation.batch_set_attribute.args.key'), + ], + 'value' => [ + 'type' => GraphQL::type('String'), + 'description' => __('enjin-platform::mutation.batch_set_attribute.args.value'), + ], + ]; + } +} diff --git a/src/GraphQL/Types/BeamClaimType.php b/src/GraphQL/Types/BeamClaimType.php index 843d90f..650fb79 100644 --- a/src/GraphQL/Types/BeamClaimType.php +++ b/src/GraphQL/Types/BeamClaimType.php @@ -96,6 +96,10 @@ public function fields(): array 'is_relation' => false, 'excludeFrom' => ['GetBeam', 'GetBeams'], ], + 'attributes' => [ + 'type' => GraphQL::type('[AttributeType]'), + 'description' => __('enjin-platform-beam::type.attribute.description'), + ], ]; } } diff --git a/tests/Feature/GraphQL/Resources/GetClaims.graphql b/tests/Feature/GraphQL/Resources/GetClaims.graphql index 3a79806..2f33690 100644 --- a/tests/Feature/GraphQL/Resources/GetClaims.graphql +++ b/tests/Feature/GraphQL/Resources/GetClaims.graphql @@ -22,6 +22,10 @@ query GetClaims( claimStatus quantity identifierCode + attributes { + key + value + } wallet { account { publicKey