diff --git a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php
index fea0e6aa3887dbaa69e83b25b2f0f0aa12b45f33..48563444f53e6d94a851bf04c4702a9a97634070 100644
--- a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php
+++ b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php
@@ -111,7 +111,7 @@ public function all() {
       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, $bundle);
+          $resource_type = $this->createResourceType($entity_type, (string) $bundle);
           return array_merge($resource_types, [
             $resource_type->getTypeName() => $resource_type,
           ]);
diff --git a/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php b/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php
index 8f9e6c5ae264e75dc7366dd1101560443b59bca3..a87ca929dff7feb32c702e8582acd17a5736361c 100644
--- a/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php
+++ b/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php
@@ -50,6 +50,9 @@ protected function setUp() {
     NodeType::create([
       'type' => 'page',
     ])->save();
+    NodeType::create([
+      'type' => '42',
+    ])->save();
 
     $this->resourceTypeRepository = $this->container->get('jsonapi.resource_type.repository');
   }
@@ -91,6 +94,7 @@ public function testGet($entity_type_id, $bundle, $entity_class) {
   public function getProvider() {
     return [
       ['node', 'article', 'Drupal\node\Entity\Node'],
+      ['node', '42', 'Drupal\node\Entity\Node'],
       ['node_type', 'node_type', 'Drupal\node\Entity\NodeType'],
       ['menu', 'menu', 'Drupal\system\Entity\Menu'],
     ];
@@ -102,9 +106,9 @@ public function getProvider() {
   public function testCaching() {
     $this->assertEmpty($this->resourceTypeRepository->get('node', 'article')->getRelatableResourceTypesByField('field_relationship'));
     $this->createEntityReferenceField('node', 'article', 'field_relationship', 'Related entity', 'node');
-    $this->assertCount(2, $this->resourceTypeRepository->get('node', 'article')->getRelatableResourceTypesByField('field_relationship'));
-    NodeType::create(['type' => 'camelids'])->save();
     $this->assertCount(3, $this->resourceTypeRepository->get('node', 'article')->getRelatableResourceTypesByField('field_relationship'));
+    NodeType::create(['type' => 'camelids'])->save();
+    $this->assertCount(4, $this->resourceTypeRepository->get('node', 'article')->getRelatableResourceTypesByField('field_relationship'));
   }
 
 }