如何解决仅在 JSON 对象上对 GraphQL 执行逻辑运算符过滤器
感谢您的帮助。我正在尝试在没有数据库的 GraphQL 中执行 AND/OR 运算符。
下面是需要在数据集而不是数据库上执行的查询。请理解,我无权连接任何数据库。
{
customVisualsData(_filter: {and: [{expression: {field: "Country",like: "Canada"}},{expression: {field: "Profit",gt: "5000"}}]}) {
Country
DiscountBand
Product
Segment
Profit
}
}
转换数据集/JSON 对象看起来像这样。
[
{
"Country": "Canada","DiscountBand": "High","Product": "Paseo","Segment": "Government","COGS": 1477815,"GrossSales": 2029256,"ManufacturingPrice": 70,"UnitsSold": 12230.5,"Profit": 300289.99999999994
},{
"Country": "United States of America","Product": "VTT","Segment": "Small Business","COGS": 1461250,"GrossSales": 1753500,"ManufacturingPrice": 750,"UnitsSold": 5845,"Profit": 74288
}
]
Schema Builder,我曾经创建过 GraphQL 查询构建器。
var schema = buildSchema(`
type customVisualObject {
Country: String
DiscountBand: String
Product: String
Segment: String
COGS: Float
GrossSales: Float
ManufacturingPrice: Int
UnitsSold: Float
Profit: Float
}
type Query {
customVisualsData(_filter: FilterInput): [customVisualObject]
}
input FilterExpressionInput {
field: String!
eq: String
gt: String
gte: String
like: String
}
input FilterInput {
expression: FilterExpressionInput
and: [FilterInput!]
or: [FilterInput]
not: [FilterInput!]
}
`);
请让我知道,如果有人知道如何在 graphQL 上为此设置解析器? 有谁知道 JSON-ata 或 GraphQL 库来在 JSON 对象而不是数据库上执行如此复杂的查询? 感谢您的帮助。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。