Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug server: don't crash when a client has no caches #5479

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this one should be necessary (it's api in :apollo-normalized-cache), but I'm getting red inside IJ without it 🤷‍♀️

implementation(project(":apollo-ast"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't have been api.

api(project(":apollo-runtime"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApolloClient is in apollo-runtime, not apollo-api

}
}

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