Skip to content

Commit 16a1a61

Browse files
authored
fix(graphql): type loader needs to return null (#5467)
1 parent 0400611 commit 16a1a61

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

features/graphql/introspection.feature

-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ Feature: GraphQL introspection support
562562
Then the response status code should be 200
563563
And the response should be in JSON
564564
And the header "Content-Type" should be equal to "application/json"
565-
And the GraphQL debug message should be equal to 'Type with id "VoDummyInspectionCursorConnection" is not present in the types container'
566565
And the JSON node "data.typeNotAvailable" should be null
567566
And the JSON node "data.typeOwner.fields[1].type.name" should be equal to "VoDummyInspectionCursorConnection"
568567

src/GraphQl/Type/SchemaBuilder.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@ public function getSchema(): Schema
8787

8888
$schema = [
8989
'query' => $queryType,
90-
'typeLoader' => function (string $typeName): Type&NamedType {
91-
$type = $this->typesContainer->get($typeName);
90+
'typeLoader' => function (string $typeName): ?NamedType {
91+
try {
92+
$type = $this->typesContainer->get($typeName);
93+
} catch (TypeNotFoundException) {
94+
return null;
95+
}
9296

9397
return Type::getNamedType($type);
9498
},

0 commit comments

Comments
 (0)