Skip to content

Commit

Permalink
fix(graphql): type loader needs to return null (#5467)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanpoulain authored Mar 16, 2023
1 parent 0400611 commit 16a1a61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion features/graphql/introspection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@ Feature: GraphQL introspection support
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json"
And the GraphQL debug message should be equal to 'Type with id "VoDummyInspectionCursorConnection" is not present in the types container'
And the JSON node "data.typeNotAvailable" should be null
And the JSON node "data.typeOwner.fields[1].type.name" should be equal to "VoDummyInspectionCursorConnection"

Expand Down
8 changes: 6 additions & 2 deletions src/GraphQl/Type/SchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ public function getSchema(): Schema

$schema = [
'query' => $queryType,
'typeLoader' => function (string $typeName): Type&NamedType {
$type = $this->typesContainer->get($typeName);
'typeLoader' => function (string $typeName): ?NamedType {
try {
$type = $this->typesContainer->get($typeName);
} catch (TypeNotFoundException) {
return null;
}

return Type::getNamedType($type);
},
Expand Down

0 comments on commit 16a1a61

Please sign in to comment.