【发布时间】:2020-02-11 12:14:57
【问题描述】:
我在 graphql-spqr-0.10.0 上并使用代码优先方法,这是客户可以查询的示例类型。
@GraphQLType(name = "Activity", description = "Some activity")
public class SomeActivity {
@GraphQLQuery(description = "Unique id")
private @NotNull Long id = null;
@GraphQLQuery(description = "Activity name")
private @NotNull String name = null;
@GraphQLScalar @GraphQLQuery(description = "Activity start date time")
private @NotNull ZonedDateTime startTime = null;
...
}
我在类路径中有 graphql-java-extended-scalars(1.0 版),我在其中一个线程中读到,我可以用 @GraphQLScalar 标记 ZonedDateTime 字段,以便用 graphql.scalars.datetime.DateTimeScalar 对其进行序列化并生成ISO_OFFSET_DATE_TIME 日期格式。
这是我不认为是所需的 ISO 格式“startTime”的实际响应格式:“2017-12-29T16:59:57-06:00[America/Chicago]”
这是使用扩展标量的正确方法吗?
【问题讨论】: