簡體   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