Interface code generation breaks serialization for nested objects
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
调研方向
首先,使用 ShipmentRating schema 和 ShipmentRatingCartonEntity,重现 issue 中所示的 DgsQueryExecutor 测试失败。跟踪生成的 interface 以及针对 amountInsured projection 的嵌套 ShipmentRatingCarton 序列化过程。嵌套对象成功序列化,并且测试能够提取包含其 carton 数据的 shipment rating,即表示完成。
由索引模型根据 Issue 内容生成。
描述
generateInterfaces = true
with a schema type like:
extend type Query {
"""
Returns a `ShipmentRating` resource by ID.
"""
shipmentRating(input: ID!): ShipmentRating
"""
Returns a list of `ShipmentRating` resources with the given filters.
"""
shipmentRatings(input: ShipmentRatingsInput): [ShipmentRating]
}
extend type Mutation {
"""
Allows an API consumer to create a `shipmentRating`.
"""
createShipmentRating(input: CreateShipmentRatingInput!): ShipmentRating
"""
Allows an API consumer to calculate possible shipment ratings based on the organization's configured settings.
"""
calculateShipmentRatings(input: CalculateShipmentRatingsInput!): [ShipmentRating]
}
enum ShipmentAmountType {
BUFFER
DISCOUNT
FUEL_SURCHARGE
INSURANCE
PUBLISHED_RATE
SURCHARGE
}
"""
A Shipment rating quote that can be displayed to
"""
type ShipmentRating implements Node {
"ShipmentRating ID, prefixed with `shipmentRating_`"
id: ID!
"The quoted amount for the `ShipmentRating`"
amount: Decimal!
"Subtotal amounts of how the `ShipmentRating` amount was calculated"
amountSubtotals: ShipmentRatingSubtotals!
"The currencyCode of the amount fields."
currencyCode: CurrencyCode!
"When this `ShipmentRating` was created"
createdAt: DateTime!
"The user who created the `ShipmentRating`"
createdBy: ID!
"Breakdown of the details returned from the carrier."
details: [ShipmentRatingDetail!]
"The customer facing display name of the `ShipmentRating`."
displayName: String!
"The ISO-8601 timestamp of when the delivery could first be delivered"
minTransitAt: DateTime
"The ISO-8601 timestamp of when the delivery will be delivered"
maxTransitAt: DateTime
"""
For shipments that contain multiple fulfillment warehouses the multipleShipFromRatings will contain the individual `ShipmentRating` calculations.
The aggregated totals will be reflected on the parent object. In these cases the shipFrom location will be null.
"""
multipleShipFromRatings: [ShipmentRating]
"The `organization` associated with the `ShipmentRating`"
organization: ID!
"A carrier service level code to identify how to fulfill the shipment"
serviceLevelCode: String!
"The `location` associated with the origin of the shipment."
shipFrom: Location
"The destination `location` used to generate the shipment Quote"
shipTo: Location!
"The Carton data included in the `ShipmentRating`"
shipmentRatingCartons: [ShipmentRatingCarton!]!
"The `ShippingProfile` associated with the `ShipmentRating`"
shippingProfile: ShippingProfile!
"When this `ShipmentRating` was most recently updated."
updatedAt: DateTime!
"The user who most recently updated the `ShipmentRating`."
updatedBy: ID!
}
"""
The Carton details containing the package dimensions and items included in the `ShipmentRating`
"""
type ShipmentRatingCarton {
"The total amount that the package is insured based in the currencyCode from the `ShipmentRating`."
amountInsured: Decimal!
"The Carton associated with the `ShipmentRatingCarton`."
carton: Carton!
"The weight the carrier is charging for this carton. This could be actual or dimensional weight of the carton."
chargeableWeight: Decimal
"The Dimensional weight factor used to determine the dimensionalWeight."
dimensionalFactor: Int
"The calculated dimensionalWeight of the carton."
dimensionalWeight: Decimal
}
"""
A surcharge or discount breakdown provided by the carrier.
"""
type ShipmentRatingDetail {
"Amount for each charge as defined by the `carrier`."
amount: Decimal!
"Unique identifier that will be tied to each fee that is charged by the carrier for the `shipmentRating`."
carrierCode: String!
"The type of fee that is being broken down as part of the `shipmentRating`."
type: ShipmentAmountType!
}
"""
Subtotal amounts of how the `ShipmentRating` amount was calculated
"""
type ShipmentRatingSubtotals {
"Amount charged for the fuel surcharge by the `carrier`."
fuelSurcharge: Decimal
"Cost to insure items that is charged by the `carrier`."
insuranceCost: Decimal
"The sum of any other surcharges that are not individually broken down by the `carrier` (residential falls into this bucked)."
otherSurcharge: Decimal
"Cost of shipping as defined by the `carrier`."
shipping: Decimal!
}
"""
Input to create a non-calculated shipmentRating.
"""
input CreateShipmentRatingInput {
amount: Decimal
cartons: [ID!]!
serviceLevelCode: String!
}
"""
Input to calculate a `shipmentRating` for the given Order.
"""
input CalculateShipmentRatingsInput {
order: ID!
}
input ShipmentRatingsInput {
countryCode: CountryCode
organization: ID
serviceLevel: ID
}
type Root @key(fields: "id") @extends {
id: ID! @external
shipmentRatings: [ShipmentRating]
}
type Location @key(fields: "id") @extends {
id: ID! @external
}
type Carton @key(fields: "id")
@extends
{
id: ID! @external
}
and a hibernate entity like this:
package com.zonos.shipmentrating.shipmentRating.model;
import com.zonos.shipmentratingclient.types.IShipmentRatingCarton;
import lombok.*;
import javax.persistence.Entity;
import java.math.BigDecimal;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
public class ShipmentRatingCartonEntity {
private BigDecimal amountInsured;
private CartonEntity carton;
private BigDecimal chargeableWeight;
private Integer dimensionalFactor;
private BigDecimal dimensionalWeight;
}
fails to serialize with a DgsQueryExecutor call like this:
@Test
void getShipmentRatingTest() throws InvocationTargetException, IllegalAccessException {
// test retrieving a shipment rating by ID
ShipmentRating shipmentRating = createShipmentRating();
var projection = new ShipmentRatingProjectionRoot();
projection.id()
.amount()
.serviceLevelCode()
.shipmentRatingCartons()
.amountInsured();
GraphQLQueryRequest request = new GraphQLQueryRequest(
new ShipmentRatingGraphQLQuery.Builder()
.input(shipmentRating.getId())
.build(),
projection,
getZonosScalars()
);
ShipmentRating retrievedShipmentRating = dgsQueryExecutor.executeAndExtractJsonPathAsObject(request.serialize(),
"data." + new ShipmentRatingGraphQLQuery().getOperationName(),
new TypeRef<List<ItemEntity>>() {
});
assertNotNull(retrievedShipmentRating);
assertTrue(retrievedShipmentRating.getId().equals(shipmentRating.getId()));
assertTrue(retrievedShipmentRating.getShipmentRatingCartons().size() == 1);
}
- 主要语言
- Kotlin
- 星标
- 220
- 派生
- 123
- 平均合并
- 1 天 6 小时
- 30 天内合并 PR
- 23
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Netflix/dgs-codegen 的其他 Issue
-
Integer default values on `Float` input fields generate code that does not compile (Java and Kotlin)可能已有人在做 @0z5a 于 9 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 72/100
Netflix/dgs-codegen#1015 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 45/100
Netflix/dgs-codegen#1002 ·
维护者通常 1 天内回复
-
Object literal default value on a custom scalar fails with NoSuchElementException可能已有人在做 @nboisnea 于 49 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
Netflix/dgs-codegen#982 ·
维护者通常 1 天内回复
-
HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s).可能已有人在做 @jiholee17 于 73 天前认领。 未关闭enhancement
Netflix/dgs-codegen#954 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Support Immutable java Data Types可能重新可做 @jiholee17 于 184 天前认领,目前没有进行中的 PR。 未关闭enhancement
Netflix/dgs-codegen#944 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 Netflix/dgs-codegen 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
help wanted
难度 2/5 1-3 小时 新手友好度 88/100
DojoCodingLabs/hermit#23 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
signalapp/Signal-Android#15148 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 78/100
PranshulGG/WeatherMaster#1266 · 3 条评论 ·
维护者通常 1 天内回复