We need to create the mutation query for updating an issue.
// gql/updateIssueMutation.ts
import { gql } from 'urql'
export const EditIssueIssueMutation = gql`
mutation EditIssue($input: EditIssueInput!) {
editIssue(input: $input) {
createdAt
id
name
status
}
}
`
Next, use this mutation to allow a user to change the status of an issue
// app/_components/Status.tsx
import { EditIssueIssueMutation } from '@/gql/updateIssueMutation'
const Status = () => {
const [editResult, editIssue] = useMutation(EditIssueIssueMutation)
const onAction = async (newStatus: string) => {
await editIssue({ input: { id: issueId, status: newStatus } })
}
}