Skip to content

Commit eb1c8e4

Browse files
authored
fix(schema): Fix InvalidPluginDefinitionException calls (#1010)
1 parent 3437deb commit eb1c8e4

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/Plugin/GraphQL/Schema/SdlSchemaPluginBase.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,15 @@ protected function getSchemaDefinition() {
222222
$id = $this->getPluginId();
223223
$definition = $this->getPluginDefinition();
224224
$module = $this->moduleHandler->getModule($definition['provider']);
225-
$file = "{$module->getPath()}/graphql/{$id}.graphqls";
225+
$path = 'graphql/' . $id . '.graphqls';
226+
$file = $module->getPath() . '/' . $path;
226227

227228
if (!file_exists($file)) {
228-
throw new InvalidPluginDefinitionException(sprintf("Missing schema definition file at %s.", $file));
229+
throw new InvalidPluginDefinitionException(
230+
$id,
231+
sprintf(
232+
'The module "%s" needs to have a schema definition "%s" in its folder for "%s" to be valid.',
233+
$module->getName(), $path, $definition['class']));
229234
}
230235

231236
return file_get_contents($file) ?: NULL;

src/Plugin/GraphQL/SchemaExtension/SdlSchemaExtensionPluginBase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,14 @@ protected function loadDefinitionFile($type) {
8989
$id = $this->getPluginId();
9090
$definition = $this->getPluginDefinition();
9191
$module = $this->moduleHandler->getModule($definition['provider']);
92-
$file = "{$module->getPath()}/graphql/{$id}.{$type}.graphqls";
92+
$path = 'graphql/' . $id . '.' . $type . '.graphqls';
93+
$file = $module->getPath() . '/' . $path;
9394

9495
if (!file_exists($file)) {
95-
throw new InvalidPluginDefinitionException(sprintf("Missing schema definition file at %s.", $file));
96+
throw new InvalidPluginDefinitionException(
97+
$id,
98+
sprintf('The module "%s" needs to have a schema definition "%s" in its folder for "%s" to be valid.',
99+
$module->getName(), $path, $definition['class']));
96100
}
97101

98102
return file_get_contents($file) ?: NULL;

0 commit comments

Comments
 (0)