我正在使用GraphQL和节点来操纵MySQL数据库。 但是,对于在使用前者的最后插入ID成功插入到前一个表中之后如何将记录插入到表中,我感到困惑。
const Mutation = new GraphQLObjectType({
AddAuthor: {
type: AuthorType,
args: {
name: { type: new GraphQLNonNull(GraphQLString) },
age: { type: new GraphQLNonNull(GraphQLInt) },
},
async resolve(parent, args){
let data = {
name: args.name,
age: args.age
};
const saveAuthor = await knex.insert(data).returning('id').into('authors');
if(saveAuthor){
const insert_id = saveAuthor[0]; //from previous insertion
**//Perform a mutation to add the ID into another table which already has a mutation field.**
}
}
},
});
这怎么可能?预先感谢