GraphQLError:语法错误:无法解析意外字符“\u00A0”

hpa*_*ier 5 reactjs graphql graphql-js react-apollo

当我使用 gql(来自“graphql-tag”)进行查询/突变/订阅时,出现错误。

\n

有谁遇到过这个错误并且知道如何修复它?
\n这是我的代码:

\n
import React from \'react\';\nimport { Mutation } from \'react-apollo\';\nimport MUTATION from \'./query.js\';\nimport gql from \'graphql-tag\';\n\nconst ADD_POST_MUTATION = gql`\n  mutation addPost($content: String!, $author: String!)\xc2\xa0{\n    addPost(content: $content, author: $author) {\n      content\n      author\n    }\n  }\n`;\n\nexport default class Tool extends React.Component {\n  state = {\n    content: \'\',\n    author: localStorage.getItem(\'user\') || \'\'\n  };\n\n  handleSubmit = (e, mutation) => {\n    console.log(mutation);\n    e.preventDefault();\n    mutation({ variables: { content: this.state.content, author: this.state.author }})\n      .then(res => console.log(res))\n      .catch(e => console.log(e));\n  }\n\n  render() {\n    return (\n      <Mutation mutation={MUTATION}>\n        {(addPost, { data }) => (\n          <div>\n            <div>Poster un commentaire</div>\n            <form onSubmit={e => this.handleSubmit(e, addPost)}>\n              <textarea onChange={e => this.setState({ content: e.target.value })}></textarea>\n              <button type=\'submit\'>Poster</button>\n            </form>\n          </div>\n        )}\n      </Mutation>\n    );\n  }\n};\n
Run Code Online (Sandbox Code Playgroud)\n

此查询再次出现错误:

\n
const FETCH_POST_QUERY = gql`\n  query {\n    getPost {\n      id\n      content\n      author\n    }\n  }\n`;\n
Run Code Online (Sandbox Code Playgroud)\n

我收到这个错误:

\n

错误图片(点击查看)

\n

hpa*_*ier 4

解决了!

graphql-tag 有问题,我必须重写以确保没有不间断的空格!