diff --git a/shared/data/src/androidMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.android.kt b/shared/data/src/androidMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.android.kt new file mode 100644 index 00000000..e20716fd --- /dev/null +++ b/shared/data/src/androidMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.android.kt @@ -0,0 +1,7 @@ +package fr.androidmakers.store.graphql + +import fr.androidmakers.domain.repo.UserRepository + +actual suspend fun getIdToken(userRepository: UserRepository): String? { + return userRepository.getIdToken() +} \ No newline at end of file diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.kt index 0f15e951..8a186b56 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.kt @@ -10,6 +10,8 @@ import com.apollographql.apollo3.network.http.HttpInterceptor import com.apollographql.apollo3.network.http.HttpInterceptorChain import fr.androidmakers.domain.repo.UserRepository +expect suspend fun getIdToken(userRepository: UserRepository): String? + fun ApolloClient( sqlNormalizedCacheFactory: SqlNormalizedCacheFactory, userRepository: UserRepository, @@ -25,7 +27,7 @@ fun ApolloClient( /** * */ - val token = userRepository.getIdToken() + val token = getIdToken(userRepository) if (token != null) { addHeader("Authorization", "Bearer $token") } diff --git a/shared/data/src/iosMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.ios.kt b/shared/data/src/iosMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.ios.kt new file mode 100644 index 00000000..949aadbc --- /dev/null +++ b/shared/data/src/iosMain/kotlin/fr/androidmakers/store/graphql/ApolloClient.ios.kt @@ -0,0 +1,8 @@ +package fr.androidmakers.store.graphql + +import fr.androidmakers.domain.repo.UserRepository + +actual suspend fun getIdToken(userRepository: UserRepository): String? { + // We do not support signin on iOS? make sure that we're not sending a stale token + return null +} \ No newline at end of file