繁体   English   中英

节点 GraphQL 突变返回 NULL

[英]Nodes GraphQL Mutation returning NULL

我正在使用普通的 sql 查询,当我尝试通过突变将某些内容添加到数据库中时,我可以在控制台中看到结果,但是 graphql 操场返回 null

这里是 type.js

const XXXType = new GraphQLObjectType({
  name: "XXXType",
  description: "This represents XXX user",
  fields: () => ({
    id: { type: GraphQLInt },
    xxx_id: { type: GraphQLInt },
    xxx1_id: { type: GraphQLInt },
    xxx2_id: { type: GraphQLInt },
    is_deleted: { type: GraphQLBoolean },
  }),
});

这是我使用类型的突变

const XXXType = require("../Types/XXXType");
const deleted = require("../Types/deleted");
const DataLayer = require("../../random/random");
const addEditXXX = {
  type: XXXType,
  description: "Associate with XXX",
  args: {
    id: { type: GraphQLInt },
    xxx_id: { type: GraphQLInt },
    xxx1_id: { type: GraphQLInt },
    xxx2_id: { type: GraphQLInt },
  },
  async resolve(parent, args) {
    let errormessage = null;
    let params = {};
    params.body = {
      uid: args.xxx,
      pid: args.xxx1,
      utid: args.xxx2,
      id: args.id,
    };
    var res = null;
    res = await DataLayer.xxx_yyy_add(params);
    console.log("res", res.data);
    return res;
  },
};

修复它,问题是结果一直返回数组。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM