小编hpa*_*ier的帖子

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

当我使用 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 …
Run Code Online (Sandbox Code Playgroud)

reactjs graphql graphql-js react-apollo

5
推荐指数
1
解决办法
7104
查看次数

标签 统计

graphql ×1

graphql-js ×1

react-apollo ×1

reactjs ×1