Kotlin2 codegen implementation is eager

未关闭
#428 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
graphql, kotlin
领域
tooling

调研方向

Payload 将 GraphQLQueryRequest、DgsClient.buildQuery 和 Kotlin2 projection 实现列为相关入口;首先跟踪 projection 在这些路径中是如何生成和序列化的。将 Java 字段映射的行为与 Kotlin2 进行比较,然后验证重复选中的字段会被去重,同时保留 Query/Projection 的划分。

由索引模型根据 Issue 内容生成。

描述

Hey all,

Thanks for this amazing library. In our current setup I ran into the following. When building the query with Kotlin projections (love the feature) it's eager. When you select a field or create a projection, the string is build eagerly.

Compared to the Java implementation the fields are stored to a map and serialised when you call the .serialize() function. The result is, when you are selecting the same field multiple times it's only included once.

We try to split our projection selection which might result in duplication of selecting a field (for example a name or id property) and this is now included in the query. GraphQL does accept it but it adds extra noise to the query which is not needed.

Proposed solution

Instead of moving to the DgsClient.buildQuery still support the split between Query and Projection which is done by using the GraphQLQueryRequest. This then can use the same underlying builder pattern that is now for the Projections but instead of calling functions it's done with the same solution that is being used for the Kotlin2 implementation.

Example

Current java result

  public XProjectionRoot y() {
    getFields().put("y", null);
    return this;
  }

Current kotlin2 implementation

  public val y: XProjection
    get() {
      field("y")
      return this
    }

Proposed kotlin2 implementation

  public val y: XProjection
    get() {
      getFields().put("y", null);
      return this
    }

And instead of using the DgsClient.buildQuery function we can provide the projection to the current GraphQLQueryRequest

主要语言
Kotlin
星标
220
派生
123
平均合并
1 天 6 小时
30 天内合并 PR
23

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Netflix/dgs-codegen 的其他 Issue

查看 Netflix/dgs-codegen 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。