Skip to content

Commit

Permalink
Merge pull request #1 from ho-nl/schema-poll
Browse files Browse the repository at this point in the history
feat: disable continueous schema polling
  • Loading branch information
Maikel-Koek authored Oct 1, 2024
2 parents 31b1bd3 + e9515ef commit fd39be3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/Controller/Index/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\Result\RawFactory;
use Magento\Framework\Escaper;
use Magento\Framework\UrlInterface;

class Index extends Action implements HttpGetActionInterface
{
private \Magento\Framework\Controller\Result\RawFactory $rawFactory;
private \Magento\Framework\UrlInterface $urlBuilder;
private RawFactory $rawFactory;
private UrlInterface $urlBuilder;
private Escaper $escaper;

public function __construct(
Context $context,
\Magento\Framework\Controller\Result\RawFactory $rawFactory,
\Magento\Framework\UrlInterface $urlBuilder,
Escaper $escaper
) {
public function __construct(Context $context, RawFactory $rawFactory, UrlInterface $urlBuilder, Escaper $escaper)
{
parent::__construct($context);
$this->rawFactory = $rawFactory;
$this->urlBuilder = $urlBuilder;
Expand All @@ -37,6 +35,9 @@ public function execute()
return $rawResponse;
}

/**
* @prettier-ignore
*/
private function getEmbedScript(): string
{
return '
Expand All @@ -51,7 +52,10 @@ private function getEmbedScript(): string
new window.EmbeddedSandbox({
target: "#embedded-sandbox",
initialEndpoint: "' . $this->escaper->escapeUrl($this->getGraphqlUrl()) . '",
includeCookies: true
includeCookies: true,
initialState: {
pollForSchemaUpdates: false
}
});
</script>
</body>
Expand All @@ -61,6 +65,6 @@ private function getEmbedScript(): string

private function getGraphqlUrl(): string
{
return rtrim($this->urlBuilder->getBaseUrl([ '_scope' => 0 ]), '/') . '/graphql';
return rtrim($this->urlBuilder->getBaseUrl(['_scope' => 0]), '/') . '/graphql';
}
}

0 comments on commit fd39be3

Please sign in to comment.