Files
omnivore/packages/web/lib/networking/mutations/updatePageMutation.ts
gitstart-omnivore cec6dc5197 Rebase
2022-06-09 13:32:32 -07:00

49 lines
965 B
TypeScript

import { gql } from 'graphql-request'
import { gqlFetcher } from '../networkHelpers'
export type UpdatePageInput = {
pageId: string
title: string,
description: string,
}
export async function updatePageMutation(
input: UpdatePageInput
): Promise<string | undefined> {
const mutation = gql`
mutation {
updatePage(
input: {
pageId: "${input.pageId}"
title: "${input.title}"
description: "${input.description}"
}
) {
... on UpdatePageSuccess {
updatedPage {
id
title
url
createdAt
author
image
description
publishedAt
}
}
... on UpdatePageError {
errorCodes
}
}
}
`
try {
const data = await gqlFetcher(mutation)
const output = data as any
return output.updatePage
} catch (err) {
return undefined
}
}