如何解决更新缓存vue-apollo后缺少字段
??,
我有一个很好的变体,很幸运,我也使我的阿波罗缓存也得到了更新,但是由于某种原因,我在控制台上收到一条警告,说在更新时Missing field
后面有last_name
查询。
我的方法:
createUser() {
this.$apollo
.mutate({
mutation: gql`
mutation(
$first_name: String!
$last_name: String!
$email: String!
$phone: String!
$company: String!
$company_id: String!
$password: String!
$roll: Roll!
) {
newUser(
first_name: $first_name
last_name: $last_name
email: $email
phone: $phone
company: $company
company_id: $company_id
password: $password
roll: $roll
blocked: Activo
) {
_id
company
first_name
last_name
}
}
`,// Parametros que vienen de mi model
variables: {
first_name: this.U_name,last_name: this.U_lastName,email: this.U_email,phone: this.U_phone,company: localStorage.company,company_id: localStorage.company_id,password: this.tempPass,roll: this.U_roll
},update: (cache,{ data: { newUser } }) => {
const GETTEAM = gql`
query getSellersData($id: ID!) {
getDeveloper(id: $id) {
_id
sellers_team {
_id
first_name
last_name
email
}
}
}
`
const data = cache.readQuery({ query: GETTEAM,variables:{id: localStorage.company_id} })
data.getDeveloper.sellers_team.push(newUser)
cache.writeQuery({ query: GETTEAM,data })
},})
.then(data => {
this.tempId = data.data.newUser._id;
this.newnotification(
data.data.newUser._id,data.data.newUser.first_name,data.data.newUser.last_name
);
this.addUserToCompany()
this.popupActive = true
this.getTeam()
})
.catch(err => {
console.log(err);
});
},
这样就可以了,但是我得到了这个警告示例:
invariant.esm.js?a957:29 Missing field email in {
"_id": "5f4486e9d0e526024f7db668","company": "Dana","first_name": "Geo","las
,如果我从查询中删除了缺少的字段,它将不会显示在我的UI中。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。