删除时的中继错误:RelayMutationQuery:胖查询上的无效字段名称

csm232s

尝试提交删除突变时遇到问题。当我提交时,出现错误Uncaught Invariant Violation: RelayMutationQuery: Invalid field name on fat query, `company`.查看,创建和更新节点都可以工作。由于某些原因,我无法删除。它提到了fatQuery中的company字段,但是我在fat查询中仅有的字段是我从服务器取回的DeletedUserId。提前致谢!

成分:

import React, {Component} from 'react';
import Relay from 'react-relay';
import {Link} from 'react-router';
import DeleteUserMutation from 'mutations/DeleteUserMutation';
import styles from './EmployeeItem.css';

class EmployeeItem extends Component {
  render() {
    const {user} = this.props;
    return (
      <div className={styles.employee}>
        <p><strong>ID:</strong> {user.id}</p>
        <p><strong>First Name:</strong> {user.firstName}</p>
        <p><strong>Last Name:</strong> {user.lastName}</p>
        <p><strong>Email:</strong> {user.email}</p>
        <div className="btn-group">
          <Link to={`/company/employees/${user.id}`} className="btn btn-primary">View Employee</Link>
          <button onClick={this.handleRemove} className="btn btn-danger">Delete User</button>
        </div>
      </div>
    )
  }

  handleRemove = (e) => {
    e.preventDefault();
    const {user, company} = this.props;

    Relay.Store.commitUpdate(new DeleteUserMutation({user, company}));
  };
}

export default Relay.createContainer(EmployeeItem, {
  fragments: {
    company: () => Relay.QL`
      fragment on Company {
        id
        ${DeleteUserMutation.getFragment('company')}
      }
    `,
    user: () => Relay.QL`
      fragment on User {
        id
        firstName
        lastName
        email
        ${DeleteUserMutation.getFragment('user')}
      }
    `
  }
});

突变:

import React from 'react';
import Relay from 'react-relay';

export default class DeleteUserMutation extends Relay.Mutation {
  static fragments = {
    company: () => Relay.QL`
      fragment on Company {
        id
      }
    `,
    user: () => Relay.QL`
      fragment on User {
        id
      }
    `
  };

  getMutation() {
    return Relay.QL`mutation {deleteUser}`;
  }

  getFatQuery() {
    return Relay.QL`
      fragment on DeleteUserPayload {
        deletedUserId
      }
    `;
  }

  getVariables() {
    return {
      id: this.props.user.id,
    }
  }

  getConfigs() {
    return [{
      type: 'NODE_DELETE',
      parentName: 'company',
      parentID: this.props.company.id,
      connectionName: 'employees',
      deletedIDFieldName: 'deletedUserId'
    }]
  }

  // Wasn't sure if this was causing the error but it appears to be 
  // something else.
  // getOptimisticResponse() {
  //   return {
  //     deletedUserId: this.props.user.id
  //   }
  // }
}
内维尔

此错误是指您在getConfigs()实现中引用了“公司”这一事实NODE_DELETE配置告诉继电器如何构建通过映射节点的突变查询的存储(例如parentID)对脂肪查询(例如域parentName)。

虽然你可能不一定今天需要它,你应该添加company到突变的净荷这里脂肪查询,因为该公司正在受着这种变化。更具体地说,公司的员工联系正在被修改:)

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

jQuery验证显示动态字段名称上的错误

来自分类Dev

VBA运行时错误1004,提取范围的字段名称丢失或无效

来自分类Dev

创建视图失败。无效的字段名称

来自分类Dev

字段名称“用户名”对模型无效

来自分类Dev

实体框架提示无效的字段名称

来自分类Dev

无效的字段名称访问Web应用

来自分类Dev

使用“最大”和“计数”查询时返回字段名称

来自分类Dev

映射时,如何使Dapper忽略/删除字段名称中的下划线?

来自分类Dev

更改显示表单错误消息时django使用的字段名称

来自分类Dev

Codeigniter是否在错误报告时更改字段名称?

来自分类Dev

尝试使用烧瓶变量字段名称更新mongodb时发生错误

来自分类Dev

Codeigniter是否在错误报告时更改字段名称?

来自分类Dev

MySQL查询中的动态字段名称选择

来自分类Dev

在dapper查询中传递字段名称

来自分类Dev

仅查询Mongodb中的字段名称

来自分类Dev

子查询中的动态字段名称?

来自分类Dev

SQL Server检索子查询的字段名称

来自分类Dev

具有动态字段名称的mongo组查询

来自分类Dev

仅查询Mongodb中的字段名称

来自分类Dev

SQL查询-替换字段名称中的句点

来自分类Dev

MySQL查询中的动态字段名称选择

来自分类Dev

Excel查询中的动态字段名称

来自分类Dev

传递给存储过程的字段名称的SQL查询

来自分类Dev

查询集注释中的动态字段名称

来自分类Dev

通用实体字段名称的动态查询

来自分类Dev

Laravel 查询中的 orderBy 字段名称

来自分类Dev

Doctrine 从查询中返回奇怪的字段名称

来自分类Dev

在linq中删除字段名称选择

来自分类Dev

在linq中删除字段名称选择

Related 相关文章

热门标签

归档