Skip to content

Commit 41d1418

Browse files
authored
Merge pull request #888 from hello-liang-shan/master
Fix "No configuration for schema '' found" when route prefix is empty string
2 parents 45ce1be + 36222f6 commit 41d1418

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/GraphQLController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GraphQLController extends Controller
1919
public function query(Request $request, RequestParser $parser, Repository $config, GraphQL $graphql): JsonResponse
2020
{
2121
$routePrefix = $config->get('graphql.route.prefix', 'graphql');
22-
$schemaName = $this->findSchemaNameInRequest($request, "$routePrefix/") ?? $config->get('graphql.default_schema', 'default');
22+
$schemaName = $this->findSchemaNameInRequest($request, "$routePrefix/") ?: $config->get('graphql.default_schema', 'default');
2323

2424
$operations = $parser->parseRequest($request);
2525

tests/Unit/EmptyRoutePrefixTest.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
namespace Rebing\GraphQL\Tests\Unit;
5+
6+
use Rebing\GraphQL\Tests\TestCase;
7+
8+
class EmptyRoutePrefixTest extends TestCase
9+
{
10+
protected function getEnvironmentSetUp($app): void
11+
{
12+
parent::getEnvironmentSetUp($app);
13+
14+
$app['config']->set('graphql.route.prefix', '');
15+
}
16+
17+
public function testEmptyRoutePrefix():void
18+
{
19+
$response = $this->call('GET', '/', [
20+
'query' => $this->queries['examples'],
21+
]);
22+
23+
self::assertEquals(200, $response->getStatusCode());
24+
}
25+
}

0 commit comments

Comments
 (0)