1

我有这样的架构

type District @model {
    id: ID!
    name: String!
    workers: [Worker] @connection(name: "DistrictWorker")
}
type Service @model{
    id: ID!
    name: String!
    workers: [Worker] @connection(name: "ServiceWorker")
}
type Worker @model {
    id: ID!
    name: String!
    service: Service @connection(name: "ServiceWorker")
    district: District @connection(name: "DistrictWorker")
}

我想在通过连接应用服务和/或区域过滤器的Worker处进行查询。我想我必须编写一些自定义解析器,也许是流水线解析器,我想要一些关于如何实现它的指导。

是否有任何不同的方法来实现相同的目标。

4

1 回答 1

1

可以通过将所需的过滤器字段添加到他们各自ModelFilterInput的过滤器来过滤他们在连接上的查询。Amplify with Appsync 通过生成解析器并将它们连接到我们定义的模式中的特定表来做得很好。我想知道为什么ModelFilterInput为表生成的 's 不包括连接字段。

对于上面定义的模式,我修改了生成的代码如下:

input ModelWorkerFilterInput {
    id: ModelIDFilterInput
    name: ModelStringFilterInput
    source: ModelStringFilterInput
    phone: ModelStringFilterInput
    workerServiceId: ModelStringFilterInput # added For @connection(name: "ServiceWorker")
    workerDistrictId: ModelStringFilterInput # added For @connection(name: "DistrictWorker") 
    and: [ModelWorkerFilterInput]
    or: [ModelWorkerFilterInput]
    not: ModelWorkerFilterInput
} 
于 2019-11-18T03:49:21.290 回答