未定义传递给Parser的参数不是有效的GraphQl DocumentNode
这是我的clientmutations.js文件。我正在使用 @apollo-client的GQL。 从“@apollo/client”导入{gql};
const DELETE_CLIENT = gql`
mutation deleteClient($id: ID!) {
deleteClient(id: $id) {
id
name
email
phone
}
}
`;
这是使用查询的组件。
import { DELETE_CLIENT } from "../mutations/clientMutations";
export default function ClientRow({ client }) {
const { deleteClient } = useMutation(DELETE_CLIENT, {
variables: { id: client.id },
});
return (
<tr>
<td>{client.name}</td>
<td>{client.email}</td>
<td>{client.phone}</td>
<td>
<button className="btn btn-danger btn-sm" onClick={deleteClient}>
<FaTrash />
</button>
</td>
</tr>
);
}
我正在违反不变的侵犯:未定义传递给Parser的论点不是有效的GraphQl DocumentNode。您可能需要使用“ GraphQL-TAG”或其他方法将操作转换为我的浏览器控制台中的文档。
This is my clientMutations.js file. I am using gql from @apollo-client.
import { gql } from "@apollo/client";
const DELETE_CLIENT = gql`
mutation deleteClient($id: ID!) {
deleteClient(id: $id) {
id
name
email
phone
}
}
`;
Here is the component that uses the query.
import { DELETE_CLIENT } from "../mutations/clientMutations";
export default function ClientRow({ client }) {
const { deleteClient } = useMutation(DELETE_CLIENT, {
variables: { id: client.id },
});
return (
<tr>
<td>{client.name}</td>
<td>{client.email}</td>
<td>{client.phone}</td>
<td>
<button className="btn btn-danger btn-sm" onClick={deleteClient}>
<FaTrash />
</button>
</td>
</tr>
);
}
i am getting Invariant Violation: Argument of undefined passed to parser was not a valid GraphQL DocumentNode. You may need to use 'graphql-tag' or another method to convert your operation into a document in my browser console.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过重新启动反应来解决此问题。我还通过使用破坏对象而不是在此处使用阵列来犯了一个错误:
I was able to solve this by restarting react. I had also made a mistake by using object destructuring rather than using array destructuring here: