Skip to content

Commit

Permalink
Merge pull request #66 from pristas-peter/develop
Browse files Browse the repository at this point in the history
Release 0.3.5
  • Loading branch information
pristas-peter authored Nov 21, 2020
2 parents 5200631 + d523dfe commit d47e4c2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Query gutenberg blocks through wp-graphql

- <a href="https://wp-graphql-gutenberg.netlify.app/" target="_blank">Usage Docs</a>
- <a href="https://wpgql-slack.herokuapp.com/" target="_blank">Join our community through WpGraphQL Slack</a>
- <a href="https://join.slack.com/t/wp-graphql/shared_invite/zt-3vloo60z-PpJV2PFIwEathWDOxCTTLA" target="_blank">Join our community through WpGraphQL Slack</a>

## Install

Expand Down
3 changes: 2 additions & 1 deletion plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Description: Enable blocks in WP GraphQL.
* Author: pristas-peter
* Author URI:
* Version: 0.3.4
* Version: 0.3.5
* Requires at least: 5.4
* License: GPL-3
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
Expand Down
22 changes: 21 additions & 1 deletion src/Schema/Types/BlockTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ protected static function create_attributes_fields($attributes, $prefix) {
$fields[$name] = [
'type' => $type,
'resolve' => function ($attributes, $args, $context, $info) use ($name, $default_value) {
return $attributes[$name] ?? $default_value;
$value = $attributes[$name] ?? $default_value;
return self::normalize_attribute_value($value, $attributes['__type'][$name]['type']);
}
];
}
Expand All @@ -111,6 +112,25 @@ protected static function create_attributes_fields($attributes, $prefix) {
return $fields;
}

protected static function normalize_attribute_value($value, $type) {
switch ($type) {
case 'string':
return strval($value);
break;
case 'number':
return floatval($value);
break;
case 'boolean':
return boolval($value);
break;
case 'integer':
return intval($value);
break;
default:
return $value;
}
}

protected static function register_attributes_types($block_type, $prefix) {
$definitions = [];

Expand Down

0 comments on commit d47e4c2

Please sign in to comment.