【发布时间】:2020-08-27 20:18:45
【问题描述】:
我想要一个附加列,其中包含来自另一列的修改值: 现在我有下一个这样的代码,但它不起作用:
const { Model } = require("objection");
class TestModel extends Model {
static get tableName() {
return "testTable";
}
static get virtualAttributes() {
return ["someNewField"];
}
someNewField() {
return this.someField+'testString';
}
static get jsonSchema() {
return {
type: "object",
properties: {
someField:{ type: "string" },
},
};
}
}
module.exports = {
TestModel,
};
我遇到了类似的错误
"message": "Cannot query field \"someNewField\" on type \"testTable\".",
我的 grapql 查询:
{TestModels{
someNewField,
}
【问题讨论】:
-
请同时添加引发错误的查询
-
@MikaelLepistö 我添加了这个
标签: graphql graphql-js objection.js