更新缓存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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...