Skip to content

Commit

Permalink
remove watch
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Apr 17, 2024
1 parent daefa0d commit c74415a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package fr.androidmakers.store.graphql

import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.cache.normalized.FetchPolicy
import com.apollographql.apollo3.cache.normalized.fetchPolicy
import com.apollographql.apollo3.cache.normalized.watch
import fr.androidmakers.domain.model.Partner
import fr.androidmakers.domain.model.PartnerGroup
import fr.androidmakers.domain.repo.PartnersRepository
Expand All @@ -13,24 +10,23 @@ import kotlinx.coroutines.flow.map
class PartnersGraphQLRepository(private val apolloClient: ApolloClient): PartnersRepository {
override fun getPartners(): Flow<Result<List<PartnerGroup>>> {
return apolloClient.query(GetPartnerGroupsQuery())
.fetchPolicy(FetchPolicy.CacheAndNetwork)
.watch()
.ignoreCacheMisses()
.cacheAndNetwork()
.map {
it.dataAssertNoErrors.partnerGroups.map { partnerGroup ->
PartnerGroup(
it.map {
it.partnerGroups.map { partnerGroup ->
PartnerGroup(
title = partnerGroup.title,
partners = partnerGroup.partners.map { partner ->
Partner(
logoUrl = partner.logoUrlLight,
name = partner.name,
url = partner.url,
logoUrlDark = partner.logoUrlDark
logoUrl = partner.logoUrlLight,
name = partner.name,
url = partner.url,
logoUrlDark = partner.logoUrlDark
)
}
)
)
}
}
}
.toResultFlow()
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package fr.androidmakers.store.graphql

import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.cache.normalized.FetchPolicy
import com.apollographql.apollo3.cache.normalized.fetchPolicy
import com.apollographql.apollo3.cache.normalized.watch
import fr.androidmakers.domain.model.Room
import fr.androidmakers.domain.repo.RoomsRepository
import kotlinx.coroutines.flow.Flow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package fr.androidmakers.store.graphql

import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.cache.normalized.FetchPolicy
import com.apollographql.apollo3.cache.normalized.fetchPolicy
import com.apollographql.apollo3.cache.normalized.watch
import com.apollographql.apollo3.exception.DefaultApolloException
import fr.androidmakers.domain.model.Speaker
import fr.androidmakers.domain.repo.SpeakersRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package fr.androidmakers.store.graphql

import com.apollographql.apollo3.ApolloClient
import com.apollographql.apollo3.cache.normalized.FetchPolicy
import com.apollographql.apollo3.cache.normalized.fetchPolicy
import com.apollographql.apollo3.cache.normalized.watch
import fr.androidmakers.domain.model.Venue
import fr.androidmakers.domain.repo.VenueRepository
import kotlinx.coroutines.flow.Flow
Expand All @@ -12,12 +9,7 @@ import kotlinx.coroutines.flow.map
class VenueGraphQLRepository(private val apolloClient: ApolloClient): VenueRepository {
override fun getVenue(id: String): Flow<Result<Venue>> {
return apolloClient.query(GetVenueQuery(id))
.fetchPolicy(FetchPolicy.CacheAndNetwork)
.watch()
.ignoreCacheMisses()
.map {
it.dataAssertNoErrors.venue.toVenue()
}
.toResultFlow()
.cacheAndNetwork()
.map { it.map { it.venue.toVenue() } }
}
}

0 comments on commit c74415a

Please sign in to comment.