Apollo 3.3.2 Kotlin从KMM中的可选值逃脱
我有一个KMM项目,该项目使用 Apollo GraphQl版本3.3.2
以前的Apollo版本都可以使用,但是我必须使用 optional.presentifnotnull($ variable)这样。
val officeId = QueryTrainingsForUserWhereWhereConditions(
Optional.presentIfNotNull(TrainingColumn.OFFICE_ID),
Optional.presentIfNotNull(SQLOperator.IS_NULL)
)
在我使用 apollo v2 之前,就像这个一样
val officeId = QueryTrainingsForUserWhereWhereConditions(
TrainingColumn.OFFICE_ID,
SQLOperator.IS_NULL
)
,我试图在gradle文件中设置,
generateOptionalOperationVariables.set(false) and try with true
但它不起作用
,当我单击 queryTrainingSforuserWherwhereConditions 时
Apollo生成了这样的代码,
public data class QueryTrainingsForUserWhereWhereConditions(
/**
* The column that is used for the condition.
*/
public val column: Optional<TrainingColumn?> = Optional.Absent,
/**
* The operator that is used for the condition.
*/
public val `operator`: Optional<SQLOperator?> = Optional.Absent,
/**
* The value that is used for the condition.
*/
public val `value`: Optional<Any?> = Optional.Absent,
/**
* A set of conditions that requires all conditions to match.
*/
public val AND: Optional<List<QueryTrainingsForUserWhereWhereConditions>?> = Optional.Absent,
/**
* A set of conditions that requires at least one condition to match.
*/
public val OR: Optional<List<QueryTrainingsForUserWhereWhereConditions>?> = Optional.Absent,
/**
* Check whether a relation exists. Extra conditions or a minimum amount can be applied.
*/
public val HAS: Optional<QueryTrainingsForUserWhereWhereConditionsRelation?> = Optional.Absent,
)
我不记得Apollo V2 之前的生成代码是什么。
很难使用此optional.presentifnotnull
。无处不在的方法,我不想使用此
是否有任何解决方案来解决我的问题或其他任何使用可选的方法。presentifnotnull来处理可选变量?
谢谢
i have a kmm project which using apollo graphql version 3.3.2
Everything okay with the previous apollo version but the new version i have to set variables with Optional.presentIfNotNull($variable) like this.
val officeId = QueryTrainingsForUserWhereWhereConditions(
Optional.presentIfNotNull(TrainingColumn.OFFICE_ID),
Optional.presentIfNotNull(SQLOperator.IS_NULL)
)
Before when i use apollo v2 it was like this
val officeId = QueryTrainingsForUserWhereWhereConditions(
TrainingColumn.OFFICE_ID,
SQLOperator.IS_NULL
)
i tried to set
generateOptionalOperationVariables.set(false) and try with true
in gradle file but it didn't work
and when i click the QueryTrainingsForUserWhereWhereConditions
apollo generated the code like this
public data class QueryTrainingsForUserWhereWhereConditions(
/**
* The column that is used for the condition.
*/
public val column: Optional<TrainingColumn?> = Optional.Absent,
/**
* The operator that is used for the condition.
*/
public val `operator`: Optional<SQLOperator?> = Optional.Absent,
/**
* The value that is used for the condition.
*/
public val `value`: Optional<Any?> = Optional.Absent,
/**
* A set of conditions that requires all conditions to match.
*/
public val AND: Optional<List<QueryTrainingsForUserWhereWhereConditions>?> = Optional.Absent,
/**
* A set of conditions that requires at least one condition to match.
*/
public val OR: Optional<List<QueryTrainingsForUserWhereWhereConditions>?> = Optional.Absent,
/**
* Check whether a relation exists. Extra conditions or a minimum amount can be applied.
*/
public val HAS: Optional<QueryTrainingsForUserWhereWhereConditionsRelation?> = Optional.Absent,
)
i couldn't remember what was the generated code before with apollo v2.
it's very hard to use this Optional.presentIfNotNull
. method in everywhere and i dont want to use this
Is there any solution to fix my problem or any other way to use Optional.presentIfNotNull to handle optional variables ?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论