diff --git a/shared/data/build.gradle.kts b/shared/data/build.gradle.kts index 682e422e..8c6749ab 100644 --- a/shared/data/build.gradle.kts +++ b/shared/data/build.gradle.kts @@ -51,7 +51,10 @@ apollo { introspection { schemaFile.set(file("src/commonMain/graphql/schema.graphqls")) - endpointUrl.set("https://androidmakers-2023.ew.r.appspot.com/graphql") + endpointUrl.set("https://confetti-app.dev/graphql") + + // This header is not needed to fetch the schema but it's read by the Apollo IDE plugin which will inject it when executing queries + headers.set(mapOf("conference" to "androidmakers2024")) } } } diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt index 96c44cd4..16d62eb3 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/SpeakersGraphQLRepository.kt @@ -9,26 +9,28 @@ import fr.androidmakers.domain.repo.SpeakersRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map -class SpeakersGraphQLRepository(private val apolloClient: ApolloClient): SpeakersRepository { +class SpeakersGraphQLRepository(private val apolloClient: ApolloClient) : SpeakersRepository { override fun getSpeakers(): Flow>> { return apolloClient.query(GetSpeakersQuery()) - .watch() - .ignoreCacheMisses() - .map { - it.dataAssertNoErrors.speakers.map { it.speakerDetails.toSpeaker() } - }.toResultFlow() + .fetchPolicy(FetchPolicy.CacheAndNetwork) + .watch() + .ignoreCacheMisses() + .map { + it.dataAssertNoErrors.speakers.map { it.speakerDetails.toSpeaker() } + }.toResultFlow() } override fun getSpeaker(id: String): Flow> { return apolloClient.query(GetSpeakersQuery()) - .fetchPolicy(FetchPolicy.CacheAndNetwork) - .watch() - .ignoreCacheMisses() - .map { - it.dataAssertNoErrors.speakers.map { it.speakerDetails }.singleOrNull { it.id == id }?.toSpeaker() - ?: error("no speaker") - } - .toResultFlow() + .fetchPolicy(FetchPolicy.CacheAndNetwork) + .watch() + .ignoreCacheMisses() + .map { + it.dataAssertNoErrors.speakers.map { it.speakerDetails }.singleOrNull { it.id == id } + ?.toSpeaker() + ?: error("no speaker") + } + .toResultFlow() } }