Apollo Android 正在生成一个具有不一致大写变量的数据类

问题描述

我使用 Apollo Android v2.1.0,并且有一个 mutation 和一组自动生成的输入类:

mutation MyMutation($values: [MyInputClass!]) {
    exampleApi(values: $values)
}

MyInputClass 具有以大写和小写字母开头的输入字段:

{
   "kind":"INPUT_OBJECT","name":"MyInputClass","description":null,"fields":null,"inputFields":[
      {
         "name":"id","type":{
            "kind":"NON_NULL","name":null,"ofType":{
               "kind":"SCALAR","name":"String","ofType":null
            }
         },"defaultValue":null
      },{
         "name":"Orientation","type":{
            "kind":"SCALAR","name":"Int","ofType":null
         },"defaultValue":null
      }
   ]
}

当 Apollo Android 尝试为 MyInputClass 生成数据类时,它失败了:

Unresolved reference: Orientation

这是由于结果 MyInputClass.kt 使用 orientationOrientation 不一致造成的:

if (this@MyInputClass.Orientation.defined) {
   writer.writeInt("orientation",this@MyInputClass.orientation.value)
}

解决方法

这是旧版本库的问题,fixed in v2.4.5。将您的库至少更新到该版本以解决该问题。

Here is the issue for ithere is the fix