Cha*_*ith 7 graphql aws-amplify
我需要创建一个可搜索的列表,其中某些记录的类型为ORGANIZATION或RESOURCE。这种关系是一对多的。因此,一个组织可以拥有许多资源。如何在一个模型下建立这种关系?
使用AWS Amplify GraphQL API ...
像这样? schema.graphql
enum ListingType {
ORGANIZATION
RESOURCE
}
type Listing @model {
id: ID!
title: String!
type: ListingType!
orginzation: Listing
}
Run Code Online (Sandbox Code Playgroud)
但是,在“突变”中,创建第一个资源时无法引用上级组织:
您需要@connection为任何关系字段包含一个指令,如文档中所述。在这种情况下,类似这样的事情应该起作用:
type Listing @model {
id: ID!
title: String!
type: ListingType!
organization: Listing @connection
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
381 次 |
| 最近记录: |