问题描述
我尝试请求过滤多对多关系的表,但在放大 graphql 或 dynamoDB 上似乎不可能。
我的问题是:如何通过 topicId 和 ProductTypeID 过滤来选择所有品牌?
不管是什么解决方案,dynamoDb sdk,elastic @searchable 数据,在 dynamo db,partiQL 上扫描,直接在 graphql 解析器上。不管我拿什么。
这里是我的 graphql 架构:
type Topic @model
@key(name: "topicByName",fields: ["name"])
@searchable
{
id: ID!
name: String!
color: String
icon: String
brands: [BrandTopic] @connection(keyName: "byTopic",fields: ["id"])
}
type BrandTopic @model
@key(name: "byTopic",fields: ["topicID","brandID"])
@key(name: "byBrand",fields: ["brandID","topicID"])
{
id: ID!
topicID: ID!
brandID: ID!
topic: Topic! @connection(fields: ["topicID"])
brand: Brand! @connection(fields: ["brandID"])
}
type ProductType @model
@key(name: "productTypesByName",fields: ["name"])
@searchable
{
id: ID!
name: String!
color: String
icon: String
brands: [BrandProductType] @connection(keyName: "byProductType",fields: ["id"])
}
type BrandProductType @model(queries: null)
@key(name: "byProductType",fields: ["productTypeID","productTypeID"])
{
id: ID!
productTypeID: ID!
brandID: ID!
productType: ProductType! @connection(fields: ["productTypeID"])
brand: Brand! @connection(fields: ["brandID"])
}
type Brand @model
@key(name: "ByName",fields: ["name"])
@searchable
{
id: ID!
name: String!
link: String
image: String
bio: String
topics: [BrandTopic] @connection(keyName: "byBrand",fields: ["id"])
productTypes: [BrandProductType] @connection(keyName: "byBrand",fields: ["id"])
createdAt: AWSDateTime! #important to keep it to have filter with keys
updatedAt: AWSDateTime! #important to keep it to have filter with keys
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)