0

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()

Always shows the error :enter image description here

What might be wrong ?

kaqqao
  • 12,984
  • 10
  • 64
  • 118
Belvi Nosakhare
  • 3,107
  • 5
  • 32
  • 65

1 Answers1

-1

I had similar issue making a graphql call from android-client

I solved it by removing the all the Dates types (createAt, updatedAt, etc) from my graphql queries.

Also, if you have to added "_id" to your gradle dependencies remove the _id build and then run

You can also follow official apollo-android document to add custom scalar types https://github.com/apollographql/apollo-android#custom-scalar-types

It should work perfectly

Paul Kumchi
  • 211
  • 4
  • 7