Skip to content

Commit d81ba4f

Browse files
committed
Add caching
1 parent 83b5473 commit d81ba4f

File tree

1 file changed

+7
-1
lines changed
  • app/src/main/java/guide/graphql/toc/data

1 file changed

+7
-1
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
packageguide.graphql.toc.data
22

33
importcom.apollographql.apollo.ApolloClient
4+
importcom.apollographql.apollo.cache.normalized.lru.EvictionPolicy
5+
importcom.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory
46

57
object Apollo{
68
val client:ApolloClient by lazy{
9+
val cacheFactory =
10+
LruNormalizedCacheFactory(EvictionPolicy.builder().maxSizeBytes(10*1024*1024).build())
11+
712
ApolloClient.builder()
813
.serverUrl("https://api.graphql.guide/graphql")
14+
.normalizedCache(cacheFactory)
915
.build()
1016
}
11-
}
17+
}

0 commit comments

Comments
(0)