我的查询过滤器
export const resolvers = {
Query: {
allItems: (_, { value }) => getAllLinks()
.then(result => filter(result, val => val.custom_attributes
.find(customVal =>
customVal.attribute_code === 'category_ids' && isEqual(customVal.value, value)
)
)),
},
Run Code Online (Sandbox Code Playgroud)
我的架构
const typeDefs = `
type Item {
id: ID!
name: String
price: Float
custom_attributes: [CUSTOM_ATTRIBUTES]
}
union CUSTOM_ATTRIBUTES = CustomString | CustomArray
type CustomString {
attribute_code: String
value: String
}
type CustomArray {
attribute_code: String
value: [String]
}
type Query {
allItems(value : [String]): [Item]!
}
`; …Run Code Online (Sandbox Code Playgroud)