Graphql 将Strapi连接到NextJS/Apollo客户端图形Ql——变量$输入“;所需类型';XXX和x27;没有提供
请原谅,这是非常基本的,但我已经有一年左右没有使用GraphQL了,我忽略了明显的问题。我正在尝试使用GraphQL将Strapi后端连接到NextJS/Apollo客户端前端,基本语法让我摸不着头脑。(这是我们正在进行的一个项目的“概念证明”,只是为了看看我们是否可以在我们的用例中使用Strapi、NextJS和富文本编辑器) Strapi为我提供了Graphql 将Strapi连接到NextJS/Apollo客户端图形Ql——变量$输入“;所需类型';XXX和x27;没有提供,graphql,tinymce,react-apollo,apollo-client,strapi,Graphql,Tinymce,React Apollo,Apollo Client,Strapi,请原谅,这是非常基本的,但我已经有一年左右没有使用GraphQL了,我忽略了明显的问题。我正在尝试使用GraphQL将Strapi后端连接到NextJS/Apollo客户端前端,基本语法让我摸不着头脑。(这是我们正在进行的一个项目的“概念证明”,只是为了看看我们是否可以在我们的用例中使用Strapi、NextJS和富文本编辑器) Strapi为我提供了createPost端点 据我所知,我需要向其发送一个包含文本的字段data的对象。我正在使用TinyMCE的编辑器编辑文本,并使用apollo
createPost
端点
据我所知,我需要向其发送一个包含文本的字段data
的对象。我正在使用TinyMCE的编辑器编辑文本,并使用apollo挂钩获得变异
const TheEditor = () => {
const [addPost, {data}] = useMutation(ADD_POST);
const [theText, setText] = useState('')
const handleEditorChange = (content, editor) => {
console.log('Content was updated:', content);
setText(content)
}
return <>
<Editor apiKey='4564654765476547654'
initialValue="<p>This is the initial content of the editor</p>"
init={{
height: 500,
menubar: false,
plugins: [
'advlist autolink lists link image charmap print preview anchor',
'searchreplace visualblocks code fullscreen',
'insertdatetimse media table paste code help wordcount'
],
toolbar:
'undo redo | formatselect | bold italic backcolor | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | help'
}}
onEditorChange={handleEditorChange}
/>
<button onClick={async e => {
e.preventDefault();
await addPost({variables: {data:theText}});
}}>ENTER
</button>
</>
}
export default withApollo(TheEditor);
但是我得到了错误
很明显,问题是我需要回去再次学习GraphQL语法的基础知识。与此同时,我希望有人能指出我的(惊人的)错误。我一直在跟随阿波罗教程,但我似乎无法从他们的代码跳到我的代码。非常感谢您的帮助。您输入的变量名不是数据
<button onClick={async e => {
e.preventDefault();
await addPost({variables: { input:theText }});
}}>ENTER
</button>
{
e、 预防默认值();
等待addPost({变量:{input:theText}});
}}>进入
变量
应包含此变异的输入
属性,而不是数据
<button onClick={async e => {
e.preventDefault();
await addPost({variables: { input:theText }});
}}>ENTER
</button>