making a graphql call using Apolloclient-Android:
apolloClient().mutate(RegisterCardTokenMutation.builder().token(token).build()).enqueue(object : ApolloCall.Callback<RegisterCardTokenMutation.Data>() {
override fun onFailure(e: ApolloException) {
emitter.onError(e)
}
override fun onResponse(response: Response<RegisterCardTokenMutation.Data>) {
emitter.onNext((response.data() as RegisterCardTokenMutation.Data).registerCreditCard())
emitter.onComplete()
}
})
here is the apollo client.
private fun apolloClient(): ApolloClient =
ApolloClient.builder().serverUrl(BASE_URL)
.okHttpClient(OkHttpClient.Builder()
.addInterceptor { chain ->
val original = chain.request()
val builder = original.newBuilder().method(original.method(), original.body())
builder.header("Authorization", "TOKEN")
chain.proceed(builder.build())
}
.build())
.addCustomTypeAdapter(CustomType.TOKEN, customTypeAdapter.tokenCustomAdapter)
.build()
What might be wrong ?