【发布时间】:2020-02-29 04:07:33
【问题描述】:
我得到了一个从 AWS-Amplify GraphQL(我相信它使用 apollo-codegen)自动生成的 TypeScript 类型,如下所示:
export type GetNoteQuery = {
getNote: {
__typename: "Note",
id: string,
createdAt: string | null,
updatedAt: string | null,
title: boolean | null,
content: string | null,
} | null,
当使用返回的数据时,我想生成一个基本类型的“Note”作为“基本”类型在我的代码中使用。 IE。将注释映射到 React 组件等。
有没有办法缩小这种自动生成的类型,或者以某种方式扩展它,让它看起来像:
type Note = {
id: string,
createdAt: string | null,
updatedAt: string | null,
title: boolean | null,
content: string | null
}
【问题讨论】:
标签: typescript graphql aws-amplify aws-appsync