@@ -33,13 +33,7 @@ public function schema($schema = null)
3333 $ this ->type ($ name );
3434 }
3535
36- $ schemaName = is_string ($ schema ) ? $ schema : config ('graphql.default_schema ' , 'default ' );
37-
38- if (!is_array ($ schema ) && !isset ($ this ->schemas [$ schemaName ])) {
39- throw new SchemaNotFound ('Type ' .$ schemaName .' not found. ' );
40- }
41-
42- $ schema = is_array ($ schema ) ? $ schema :$ this ->schemas [$ schemaName ];
36+ $ schema = $ this ->getSchemaConfiguration ($ schema );
4337
4438 $ schemaQuery = array_get ($ schema , 'query ' , []);
4539 $ schemaMutation = array_get ($ schema , 'mutation ' , []);
@@ -69,7 +63,7 @@ public function schema($schema = null)
6963 $ mutation = $ this ->objectType ($ schemaMutation , [
7064 'name ' => 'Mutation '
7165 ]);
72-
66+
7367 $ subscription = $ this ->objectType ($ schemaSubscription , [
7468 'name ' => 'Subscription '
7569 ]);
@@ -336,4 +330,15 @@ public static function routeNameTransformer ($name, $schemaParameterPattern, $qu
336330
337331 return $ routeName ?: preg_replace ($ schemaParameterPattern , '{ ' . $ name . '} ' , $ queryRoute );
338332 }
333+
334+ protected function getSchemaConfiguration ($ schema )
335+ {
336+ $ schemaName = is_string ($ schema ) ? $ schema : config ('graphql.default_schema ' , 'default ' );
337+
338+ if (!is_array ($ schema ) && !isset ($ this ->schemas [$ schemaName ])) {
339+ throw new SchemaNotFound ('Type ' . $ schemaName . ' not found. ' );
340+ }
341+
342+ return is_array ($ schema ) ? $ schema : $ this ->schemas [$ schemaName ];
343+ }
339344}
0 commit comments