我正在尝试运行graphql突变来创建dynamoDB的用户。运行突变时,我期望它返回新创建的用户。但是,即使我的数据已成功添加到数据库中,而我的解析器返回了正确的类型,返回的数据也始终为空。
我的突变方案:
X
我的解析器:
input UserInput {
active: Boolean!
email: String!
fullname: String!
description: String!
tags: [String!]!
}
type User {
active: Boolean!
email: String!
fullname: String!
description: String!
tags: [String!]!
}
type Mutation {
createUser(input: UserInput!): User!
}
最后,我的userAPI是:
Mutation: {
createUser: (_, user, { dataSources }) => {
return dataSources.userAPI.createUser(user)
}
}
我总是收到一条错误消息:“无法为不可为空的字段返回null...。”为什么会这样?