微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AWS-CDK Appsync Codefirst 输入类型

如何解决AWS-CDK Appsync Codefirst 输入类型

为了避免重复数据结构,我想在这样的输入类型上重用类型定义

export const DeviceStatus = new ObjectType('DeviceStatus',{
    deFinition: {
        time: timestamp,firmwareversion: string
    },});

export const DeviceStatusInput = new InputType('DeviceStatusInput',{
    deFinition: {
        tenantId: id_required,deviceid: id_required,// Reuse of DeviceStatus Field deFinition
        status: DeviceStatus.attribute()
    }
});

没有错误,因为 DeviceStatus.attribute() 的返回类型很好,这适用于 ObjectType 继承。

从我的角度来看,这应该可行,但部署会导致令人讨厌的“创建架构的内部错误错误

当然我可以将整个定义移动到一个对象中并重用它,但这看起来很奇怪。 CodeFirst 方法对此有什么好的解决方

解决方法

object type 中引用 input type 似乎无效。

我建议查看Can you make a graphql type both an input and output type?

可能最好的办法是创建一些方便的方法,该方法将从单一定义中创建对象和输入类型。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。