我的架构如下设置:
updatePost(id: ID!, data: UpdatePostInput!): Post!
我也将前端查询设置如下:
export const UPDATE_POST_MUTATION = gql`
mutation UpdatePost($id: ID!, $title: String, $body: String, $location: String, $published: Boolean) {
updatePost(
id: $id,
data: {
title: $title, body: $body, location: $location, published: $published
}
){
id
title
body
}
}
`
如果在这种情况下我想使用useMutation
,我将如何包含ID和变量?
我尝试了以下操作,但没有成功:
const formSubmit = useMutation(UPDATE_POST_MUTATION, {
variables: { id: props.match.params.id, variables } // or ...variables
})