Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include 'frontend' field for Wysiwyg Editables #783

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions doc/10_GraphQL/04_Query/01_Document_Queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,51 @@
}
```

### Fetch Document Page and get processed Wysiwyg editable content

* Field `text` contains the HTML as it is stored in Pimcore for this Wysiwyg editable.
* Field `frontend` contain the processed HTML where Pimcore Element links are rewritten where necessary.

```graphql
{
getDocument(id: 207) {
... on document_page {
id,
editables(getInheritedValues: true){
__typename
...on document_editableWysiwyg {
text
frontend
}
}
}
}
}
```

### Fetch Full Rendered Document Page

The `rendered` field can be used to retrieve a rendered version of the page. Available options:
* `attributes`: Attributes passed into the controller/action
* `query`: Query Params passed into the controller/action
* `options`: Options passed into the renderer
* `use_layout`: Enable/disable Layout Rendering

```graphql
{
getDocument(id: 207) {
... on document_page {
id,
rendered(
attributes: [{key: "myControllerAttributeName", value: "Hello World!"}],
use_layout: true,
options: [{key: "ignore_errors", value: "1"}]
)
}
}
}
```

## Fetch Document Page via Data Object Relation and Get More Editable Data

* get data object ID 61
Expand Down
9 changes: 9 additions & 0 deletions src/GraphQL/DocumentElementType/WysiwygType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

namespace Pimcore\Bundle\DataHubBundle\GraphQL\DocumentElementType;

use GraphQL\Type\Definition\Type;
use Pimcore\Model\Document\Editable\Wysiwyg;

class WysiwygType extends SimpleTextType
{
protected static $instance;
Expand All @@ -26,6 +29,12 @@ public static function getInstance()
{
if (!self::$instance) {
$config = self::getStandardConfig('document_editableWysiwyg');

$config['fields']['frontend'] = [
'type' => Type::string(),
'resolve' => static fn (Wysiwyg $value) => $value->frontend(),
];

self::$instance = new static($config);
}

Expand Down
Loading