GraphQL - Apollo - Android - Kotlin - Пользовательские типы не генерируются даже после их указания в build.gradle - PullRequest
0 голосов
/ 28 мая 2020

Я использую Apollo Client и Graph Ql для своего проекта, я пытаюсь использовать CustomTypeAdapter и сопоставить одно из полей, присутствующих в schema, с настраиваемым полем. Но сгенерированный пользовательский тип не содержит значения, которое я указываю в build.gradle.

Ниже указан уровень моего приложения build.gradle

 apollo {
        generateKotlinModels.set(true) // or false for Java models
        customTypeMapping = [
                "PersonDetail": "com.task.databasepoc.models.Person"
        ]
    }

Ниже приведен уровень моего проекта build.gradle:

dependencies {
        classpath "com.apollographql.apollo:apollo-gradle-plugin:2.0.3"
    }

Ниже мой CustomTypeAdapter:

object TypeAdapter : CustomTypeAdapter<Person> {
        override fun decode(value: CustomTypeValue<*>): Person {
            return value as Person
        }

        override fun encode(value: Person): CustomTypeValue<*> {
            return CustomTypeValue.fromRawValue(value)
        }


    }

Я пытаюсь построить ApolloClient, как показано ниже:

fun getApolloClient(): ApolloClient {
        val httpLoggingInterceptor = HttpLoggingInterceptor()
        httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.BODY

        val okHttpClient = OkHttpClient.Builder()
            .addInterceptor(httpLoggingInterceptor)
            //.addInterceptor(AuthHeaderInterceptor(authStorageService))
            //.addInterceptorInterceptor(CorrelationIdInterceptor(correlationIdProvider))
            .connectTimeout(10000, TimeUnit.MILLISECONDS)
            .writeTimeout(30000, TimeUnit.MILLISECONDS)
            .readTimeout(30000, TimeUnit.MILLISECONDS)
            .build()
        return ApolloClient.builder()
            .serverUrl("serverUrl")
            .okHttpClient(okHttpClient)
            .addCustomTypeAdapter(CustomType.PersonDetail, TypeAdapter)
            .build()
    }

CustomType класс не содержат PersonDetail.

Я пробовал rebuilding, syncing все, но бесполезно.

Кто-нибудь, пожалуйста, скажите мне, что мне здесь не хватает?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...