Skip to content

Commit

Permalink
Debug server: don't crash when a client has no caches (#5479)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD authored Dec 14, 2023
1 parent 5056a5b commit 1f6fcc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libraries/apollo-debug-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ internal class GraphQLApolloClient(

fun displayName() = id

fun normalizedCaches(): List<NormalizedCache> = runBlocking { apolloClient.apolloStore.dump() }.map {
NormalizedCache(id, it.key, it.value)
fun normalizedCaches(): List<NormalizedCache> {
val apolloStore = runCatching { apolloClient.apolloStore }.getOrNull() ?: return emptyList()
return runBlocking { apolloStore.dump() }.map {
NormalizedCache(id, it.key, it.value)
}
}

fun normalizedCache(id: String): NormalizedCache? {
Expand Down

0 comments on commit 1f6fcc0

Please sign in to comment.