Files
omnivore/packages/web/lib/networking/mutations/updateLabelMutation.ts
2022-03-30 12:24:29 +00:00

53 lines
1.1 KiB
TypeScript

import { gql } from 'graphql-request'
import { gqlFetcher } from '../networkHelpers'
export type UpdateLabelInput = {
labelId: string
name: string,
color: string,
description?: string
}
export async function updateLabelMutation(
input: UpdateLabelInput
): Promise<string | undefined> {
const mutation = gql`
mutation {
updateLabel(
input: {
color: "${input.color}"
name: "${input.name}"
description: "${input.description}"
labelId: "${input.labelId}"
}
) {
... on UpdateLabelSuccess {
label {
id
name
color
description
createdAt
}
}
... on UpdateLabelError {
errorCodes
}
}
}
`
try {
console.log('here', input)
const data = await gqlFetcher(mutation)
console.log('here 3')
console.log(input, data);
const output = data as any
console.log(output)
return output?.updatedLabel
} catch (err) {
console.log('here 3', err)
return undefined
}
}