Apollo 3.3.2 Kotlin从KMM中的可选值逃脱

发布于 2025-02-13 05:02:40 字数 2085 浏览 0 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文