diff --git a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php
index 683fbd9a8b00e1d63e321214c904a0507e4bc177..faa7017455c56b993b4f274c47a4a420d2360a51 100644
--- a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php
+++ b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php
@@ -118,24 +118,27 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Ent
    */
   public function all() {
     $cached = $this->cache->get('jsonapi.resource_types', FALSE);
-    if ($cached === FALSE) {
-      $resource_types = [];
-      foreach ($this->entityTypeManager->getDefinitions() as $entity_type) {
-        $bundles = array_keys($this->entityTypeBundleInfo->getBundleInfo($entity_type->id()));
-        $resource_types = array_reduce($bundles, function ($resource_types, $bundle) use ($entity_type) {
-          $resource_type = $this->createResourceType($entity_type, (string) $bundle);
-          return array_merge($resource_types, [
-            $resource_type->getTypeName() => $resource_type,
-          ]);
-        }, $resource_types);
-      }
-      foreach ($resource_types as $resource_type) {
-        $relatable_resource_types = $this->calculateRelatableResourceTypes($resource_type, $resource_types);
-        $resource_type->setRelatableResourceTypes($relatable_resource_types);
-      }
-      $this->cache->set('jsonapi.resource_types', $resource_types, Cache::PERMANENT, $this->cacheTags);
+    if ($cached) {
+      return $cached->data;
     }
-    return $cached ? $cached->data : $resource_types;
+
+    $resource_types = [];
+    foreach ($this->entityTypeManager->getDefinitions() as $entity_type) {
+      $bundles = array_keys($this->entityTypeBundleInfo->getBundleInfo($entity_type->id()));
+      $resource_types = array_reduce($bundles, function ($resource_types, $bundle) use ($entity_type) {
+        $resource_type = $this->createResourceType($entity_type, (string) $bundle);
+        return array_merge($resource_types, [
+          $resource_type->getTypeName() => $resource_type,
+        ]);
+      }, $resource_types);
+    }
+    foreach ($resource_types as $resource_type) {
+      $relatable_resource_types = $this->calculateRelatableResourceTypes($resource_type, $resource_types);
+      $resource_type->setRelatableResourceTypes($relatable_resource_types);
+    }
+    $this->cache->set('jsonapi.resource_types', $resource_types, Cache::PERMANENT, $this->cacheTags);
+
+    return $resource_types;
   }
 
   /**