【发布时间】:2017-05-21 19:19:31
【问题描述】:
我想将一些对象类型用作输入和输出,例如货币类型或预订类型。
如何将我的架构定义为具有同时支持输入和输出的类型 - 如果不需要,我不想复制代码。我也不想创建重复的输入类型,比如货币和状态枚举。
export const ReservationInputType = new InputObjectType({
name: 'Reservation',
fields: {
hotelId: { type: IntType },
rooms: { type: new List(RoomType) },
totalCost: { type: new NonNull(CurrencyType) },
status: { type: new NonNull(ReservationStatusType) },
},
});
export const ReservationType = new ObjectType({
name: 'Reservation',
fields: {
hotelId: { type: IntType },
rooms: { type: new List(RoomType) },
totalCost: { type: new NonNull(CurrencyType) },
status: { type: new NonNull(ReservationStatusType) },
},
});
【问题讨论】:
标签: graphql graphql-js