Files
omnivore/packages/web/lib/networking/mutations/updatePageMutation.ts
2023-03-03 19:20:06 +08:00

49 lines
977 B
TypeScript

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