@@ -13,7 +13,7 @@ class ProcessGraphQL extends Process implements Module {
1313 {
1414 return array(
1515 'title' => 'GraphQL',
16- 'version' => '0.11.0',
16+ 'version' => '0.11.0',
1717 'summary' => 'GraphQL for ProcessWire.',
1818 'href' => 'https://github.com/dadish/ProcessGraphql',
1919 'singular' => true,
@@ -31,6 +31,13 @@ class ProcessGraphQL extends Process implements Module {
3131 $this->addHookAfter('Template::changed', $this, 'hookTemplateNameChange');
3232 }
3333
34+ /**
35+ * Updates the legalTemplates on name change. Template names for ProcessWire
36+ * are not necessarily valid for GraphQL field naming. Those names that are
37+ * not compatible are removed from legalFields, those that are compatible
38+ * are updated when changed.
39+ * @param HookEvent $event ProcessWire hook $event object.
40+ */
3441 public function hookTemplateNameChange(HookEvent $event)
3542 {
3643 $whatChanged = $event->arguments[0];
@@ -59,19 +66,33 @@ class ProcessGraphQL extends Process implements Module {
5966 $this->modules->saveConfig($this, 'legalTemplates', $legalTemplates);
6067 }
6168
69+ /**
70+ * Returns the GraphiQL GUI for ProcessWire admin when request's header is not
71+ * set to AJAX. Executes GraphQL api if it is AJAX.
72+ * @return string The rendered string of either GraphiQL GUI or GraphQL json
73+ * response
74+ */
6275 public function ___execute()
6376 {
6477 if ($this->config->ajax) return $this->executeGraphQL();
6578 return $this->executeGraphiQLPartial();
6679 }
6780
81+ /**
82+ * Returns a GraphiQL page.
83+ * @return string An HTML string.
84+ */
6885 public function executeGraphiQL()
6986 {
7087 $this->setupGraphiQLAssets();
7188 $fullFilename = $this->config->paths->site . 'modules/ProcessGraphQL/GraphiQL/full.php';
7289 return wireRenderFile($fullFilename);
7390 }
7491
92+ /**
93+ * Returns only the necessary parts for the GraphiQL GUI.
94+ * @return string An HTML strin.
95+ */
7596 public function executeGraphiQLPartial()
7697 {
7798 $this->setupGraphiQLAssets();
@@ -81,6 +102,9 @@ class ProcessGraphQL extends Process implements Module {
81102 ]);
82103 }
83104
105+ /**
106+ * Setups the GraphiQL js/css assets for ProcessWire to handle in the admin.
107+ */
84108 public function setupGraphiQLAssets()
85109 {
86110 $this->config->scripts->add($this->config->urls->ProcessGraphQL . 'GraphiQL/build/static/js/main.a8a92523.js');
@@ -90,13 +114,21 @@ class ProcessGraphQL extends Process implements Module {
90114 ]);
91115 }
92116
117+ /**
118+ * Returns the server url from where the GraphiQL GUI will fetch the api.
119+ * @return string Url of the GraphQL server.
120+ */
93121 public function getGraphQLServerUrl()
94122 {
95123 $url = $this->GraphQLServerUrl;
96124 if (!$url) $url = $this->pages->get('template=admin, name=' . self::pageName)->url;
97125 return $url;
98126 }
99127
128+ /**
129+ * Executes GraphQL api.
130+ * @return string GraphQL api JSON response.
131+ */
100132 public function executeGraphQL()
101133 {
102134 // instantiating Processor and setting the schema
@@ -117,7 +149,6 @@ class ProcessGraphQL extends Process implements Module {
117149
118150 /**
119151 * Install the module page under setup
120- *
121152 */
122153 public function ___install()
123154 {
@@ -139,6 +170,9 @@ class ProcessGraphQL extends Process implements Module {
139170 $this->message("Created page at: {$page->path}");
140171 }
141172
173+ /**
174+ * Delete the module page
175+ */
142176 public function ___uninstall()
143177 {
144178 // find page by process field
0 commit comments