From 1f6fcc0149045e5fc297660b7bd819bfb2a2aac8 Mon Sep 17 00:00:00 2001 From: Benoit Lubek Date: Thu, 14 Dec 2023 09:20:45 +0100 Subject: [PATCH] Debug server: don't crash when a client has no caches (#5479) --- libraries/apollo-debug-server/build.gradle.kts | 6 +++--- .../apollo3/debugserver/internal/graphql/GraphQL.kt | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libraries/apollo-debug-server/build.gradle.kts b/libraries/apollo-debug-server/build.gradle.kts index 948b3902315..7808698a736 100644 --- a/libraries/apollo-debug-server/build.gradle.kts +++ b/libraries/apollo-debug-server/build.gradle.kts @@ -24,9 +24,9 @@ kotlin { dependencies { implementation(project(":apollo-normalized-cache")) - - api(project(":apollo-ast")) - api(project(":apollo-api")) + implementation(project(":apollo-normalized-cache-api")) + implementation(project(":apollo-ast")) + api(project(":apollo-runtime")) } } diff --git a/libraries/apollo-debug-server/src/commonMain/kotlin/com/apollographql/apollo3/debugserver/internal/graphql/GraphQL.kt b/libraries/apollo-debug-server/src/commonMain/kotlin/com/apollographql/apollo3/debugserver/internal/graphql/GraphQL.kt index 35b9cba6a81..3686561def8 100644 --- a/libraries/apollo-debug-server/src/commonMain/kotlin/com/apollographql/apollo3/debugserver/internal/graphql/GraphQL.kt +++ b/libraries/apollo-debug-server/src/commonMain/kotlin/com/apollographql/apollo3/debugserver/internal/graphql/GraphQL.kt @@ -84,8 +84,11 @@ internal class GraphQLApolloClient( fun displayName() = id - fun normalizedCaches(): List = runBlocking { apolloClient.apolloStore.dump() }.map { - NormalizedCache(id, it.key, it.value) + fun normalizedCaches(): List { + val apolloStore = runCatching { apolloClient.apolloStore }.getOrNull() ?: return emptyList() + return runBlocking { apolloStore.dump() }.map { + NormalizedCache(id, it.key, it.value) + } } fun normalizedCache(id: String): NormalizedCache? {