Find the Exponential Software extensions you want
UNIX name | Owner | Status |
---|---|---|
ezplatform-graphql-page | 7x | stable |
Version | Compatible with |
---|---|
N/A | N/A |
This package integrates the eZ Platform Enterprise page features into the GraphQL API.
Add the package to composer.json:
{
"repositories": [
{"type": "git", "url": "https://github.com/ezsystems/ezplatform-graphql-page.git"}
],
"require": {
"ezsystems/ezplatform-graphql-page": "dev-master"
}
}
Enable the bundle in app/AppKernel.php:
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new BD\EzPlatformGraphQLPageBundle\BDEzPlatformGraphQLPageBundle(),
];
Update the dependencies, and regenerate the graphql schema:
composer update
php bin/console ezplatform:graphql:generate
The schema generator will create one type for each defined block type: EmbedPageBlock, HeroPageBlock... those types have a field for each attribute defined for the block.
Embed block attributes will directly give you access to the embedded object. You can then test its type, and query its properties accordingly:
... on EmbedPageBlock {
contentId {
... on BlogPostContent {
title
_location { urlAliases { path } }
}
}
}
When querying a page field, you will get access to zones, and the zone's blocks. Each block will have its own type, allowing you test for fragments, and choose which properties to query from each block.
{
pages {
landingPage(id: 235) {
page {
zones {
name
blocks {
__typename
... on EmbedPageBlock {
contentId {
... on BlogPostContent {
title
_location { urlAliases { path } }
}
}
}
}
}
}
}
}
}