简体   繁体   中英

Nodes GraphQL Mutation returning NULL

I am using normal sql queries, when i try to add something in to database via mutation, i can see the result in console, but graphql playground returns null

here is 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 },
  }),
});

here is my mutation which uses the type

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;
  },
};

Fixed it, the issue was result has been returning the array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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