Skip to content

Commit 74f23f8

Browse files
committed
Setup GraphiQL assets only when they are needed.
1 parent 837b912 commit 74f23f8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ProcessGraphQL.module

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class ProcessGraphQL extends Process implements Module {
2929
{
3030
require_once $this->config->paths->site . 'modules/ProcessGraphQL/vendor/autoload.php';
3131
$this->addHookAfter('Template::changed', $this, 'hookTemplateNameChange');
32-
$this->config->scripts->add($this->config->urls->ProcessGraphQL . 'GraphiQL/build/static/js/main.a8a92523.js');
33-
$this->config->styles->add($this->config->urls->ProcessGraphQL . 'GraphiQL/build/static/css/main.a7124171.css');
34-
$this->config->js($this->className, [
35-
'GraphQLServerUrl' => $this->getGraphQLServerUrl(),
36-
]);
3732
}
3833

3934
public function hookTemplateNameChange(HookEvent $event)
@@ -72,18 +67,29 @@ class ProcessGraphQL extends Process implements Module {
7267

7368
public function executeGraphiQL()
7469
{
70+
$this->setupGraphiQLAssets();
7571
$fullFilename = $this->config->paths->site . 'modules/ProcessGraphQL/GraphiQL/full.php';
7672
return wireRenderFile($fullFilename);
7773
}
7874

7975
public function executeGraphiQLPartial()
8076
{
77+
$this->setupGraphiQLAssets();
8178
$partialFilename = $this->config->paths->site . 'modules/ProcessGraphQL/GraphiQL/partial.php';
8279
return wireRenderFile($partialFilename, [
8380
'fullWidth' => $this->fullWidthGraphiQL,
8481
]);
8582
}
8683

84+
public function setupGraphiQLAssets()
85+
{
86+
$this->config->scripts->add($this->config->urls->ProcessGraphQL . 'GraphiQL/build/static/js/main.a8a92523.js');
87+
$this->config->styles->add($this->config->urls->ProcessGraphQL . 'GraphiQL/build/static/css/main.a7124171.css');
88+
$this->config->js($this->className, [
89+
'GraphQLServerUrl' => $this->getGraphQLServerUrl(),
90+
]);
91+
}
92+
8793
public function getGraphQLServerUrl()
8894
{
8995
$url = $this->GraphQLServerUrl;

0 commit comments

Comments
 (0)