如何解决我的应用程序中的错误:GraphQL错误:未知修饰符:$ pushAll?

时间:2018-07-30 03:24:13

标签: javascript mongoose graphql

控制台中的完整错误消息是ff:

bundle.js:6882未捕获(已承诺)错误:GraphQL错误:未知修饰符:$ pushAll     在新的ApolloError(bundle.js:6885)     在bundle.js:15810

任何人都可以向我展示如何解决此问题?

我在其他线程中读到或质疑$ pushAll是nodejs的猫鼬版本问题。这是相同的$ pushAll问题吗?

提前谢谢!

这是graphql查询:

mutation AddLyricToSong($content: String, $songId: ID) {
  addLyricToSong(content: $content, songId: $songId) {
    id
    title
    lyrics {
      content
    }
  }
}

这是一个js文件中的查询。

import React, { Component } from 'react'
import gql from 'graphql-tag';
import { graphql } from 'react-apollo';

class LyricCreate extends Component {
  constructor(props) {
    super(props);

    this.state = { content: '' };
  }

  onSubmithandler(event) {
    event.preventDefault();

    this.props.mutate({
      variables: {
        content: this.state.content,
        songId: this.props.songId
      }
    })
  }

  render() {

    return (

        <form onSubmit={this.onSubmithandler.bind(this)}>
          <label>Add a Lyric</label>
          <input 
            value={this.state.content}
            onChange={(event) => this.setState({content: event.target.value})} 
           type="text"/>
        </form>

    )
  }
}

const mutation = gql`
mutation AddLyricToSong($content: String, $songId: ID) {
  addLyricToSong(content: $content, songId: $songId) {
    id
    title
    lyrics {
      content
    }
  }
}

`;

export default graphql(mutation)(LyricCreate);

0 个答案:

没有答案