我在apollo设置中有一个解析器突变,代码如下
Mutation: {
sendInvite: async (parent, args: MutationSendInviteArgs, context) => {
console.log('args email >>>>> ', args);
// create invite code
// add to invite container
// send email with invite
const emailSent = true;
const emailMessage = 'sent invite';
// is the record added by the api connector? ---> look into this
return {
success: emailSent,
message: emailMessage,
email:args.email
}
}
}
我在操场上跑步
mutation{
sendInvite(email:["anders@email.org","anders@email.com"]){
email
success
message
}
}
我得到以下回应
"message": "String cannot represent value: [\"anders@email.org\", \"anders@email.com\"]",
哦,这是我的突变模式
type Mutation {
sendInvite(email: [String]): Invite
}
type Invite {
email: String!
success: Boolean!
message: String!
}
如何返回电子邮件,使其成为可以Map的阵列?
实际上我想返回sendinvite字段的数组,所以有多条成功消息、电子邮件和消息
提前谢谢
1条答案
按热度按时间mcdcgff01#
我必须做以下几件事