Skip to content

Commit

Permalink
Change graphql query for rangeslider to support additional fields, cl…
Browse files Browse the repository at this point in the history
…oses #15
  • Loading branch information
bryannielsen committed Oct 1, 2024
1 parent 52ed806 commit 2989ff4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- Relaxed GraphQL handling of fieldtypes during schema generation. Now errors will be logged but schemas can still be built
- Default url for ExpressionEngine Control Panel is now `admin` instead of `admin.php`. This can be changed in `config/coilpack.php`.
- TemplateOutput now implements the [Stringable](https://www.php.net/manual/en/class.stringable.php) interface
- GraphQL query signature for the Range Slider Fieldtype to support querying `value`, `from`, and `to` fields

## [1.4.2] - 2024-09-26

Expand Down
29 changes: 29 additions & 0 deletions src/Fieldtypes/RangeSlider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Expressionengine\Coilpack\Fieldtypes;

use Expressionengine\Coilpack\Api\Graph\Support\GeneratedType;
use Expressionengine\Coilpack\Facades\Coilpack;
use Expressionengine\Coilpack\FieldtypeOutput;
use Expressionengine\Coilpack\Models\FieldContent;
Expand All @@ -21,4 +22,32 @@ public function apply(FieldContent $content, $parameters = [])
return FieldtypeOutput::for($this)->value($string)->array($array);
});
}

public function graphType()
{
return new GeneratedType([
'fields' => function () {
return [
'value' => [
'type' => \GraphQL\Type\Definition\Type::string(),
'resolve' => function ($root, array $args) {
return $root;
},
],
'from' => [
'type' => \GraphQL\Type\Definition\Type::string(),
'resolve' => function ($root, array $args) {
return $root->from;
},
],
'to' => [
'type' => \GraphQL\Type\Definition\Type::string(),
'resolve' => function ($root, array $args) {
return $root->to;
},
],
];
},
]);
}
}

0 comments on commit 2989ff4

Please sign in to comment.