对于AWS amplify中的模式,graphql中的数组和映射是否有标量类型?
我正在学习使用AWS amplify with React,它使用的API是一个利用AWS AppSync的GraphQL API。我对graphQL非常陌生,目前我的模式是这样的。这是放大应用程序中的模式:对于AWS amplify中的模式,graphql中的数组和映射是否有标量类型?,graphql,aws-amplify,Graphql,Aws Amplify,我正在学习使用AWS amplify with React,它使用的API是一个利用AWS AppSync的GraphQL API。我对graphQL非常陌生,目前我的模式是这样的。这是放大应用程序中的模式: type Note @model { id: ID! name: String! description: String title: String image: String } 举个例子,我想在注释类型的组件中存储一个对象数组,如下所示: 代码-1 type No
type Note @model {
id: ID!
name: String!
description: String
title: String
image: String
}
举个例子,我想在注释类型的组件中存储一个对象数组,如下所示:
代码-1
type Note @model {
id: ID!
name: String!
description: String
title: String
image: String
components: []
}
但是在阅读文档时,我知道没有任何数组标量类型。我知道我可以创建另一个表并改为这样做:
代码-2
type Note @model {
id: ID!
name: String!
description: String
title: String
image: String
components: [elements!]!
}
type elements @model {
id: ID!
item: String!
}
但我不想要这个,因为它创建了一个新表。我只需要一个包含id、名称、描述、标题、图像和组件数组的表,您可以在其中存储对象,如上面的Code-1所示。有什么可能的方法可以做到这一点吗?另外,模式中“@modal”的作用是什么?查看了AWS文档,发现我可以将AWSJSON用于[1,2,3]之类的列表/数组和{“upvots”:10}之类的映射,所以现在我的模式是:
type Note @model {
id: ID!
name: String!
description: String
title: String
image: String
components: AWSJSON
}
下面是了解更多信息的链接“自定义JSON标量”-检查通用图形QL并放大docs@xadm非常感谢你。考虑到“AWSJSON”可以使用,我想我的错误是看graphql文档而不是AWS文档。