This will let us handle the mutations differently on native iOS and should help in avoiding making web calls directly from the web view, so we can avoid CORs and introduce a caching layer.
49 lines
983 B
TypeScript
49 lines
983 B
TypeScript
import { gql } from 'graphql-request'
|
|
import { gqlFetcher } from '../networkHelpers'
|
|
|
|
export type UpdateHighlightInput = {
|
|
highlightId: string
|
|
annotation?: string
|
|
sharedAt?: string
|
|
}
|
|
|
|
type UpdateHighlightOutput = {
|
|
updateHighlight: HighlightOutput
|
|
}
|
|
|
|
type HighlightOutput = {
|
|
highlight: HighlightId
|
|
}
|
|
|
|
type HighlightId = {
|
|
id: string
|
|
}
|
|
|
|
export async function updateHighlightMutation(
|
|
input: UpdateHighlightInput
|
|
): Promise<string | undefined> {
|
|
const mutation = gql`
|
|
mutation UpdateHighlight($input: UpdateHighlightInput!) {
|
|
updateHighlight(input: $input) {
|
|
... on UpdateHighlightSuccess {
|
|
highlight {
|
|
id
|
|
}
|
|
}
|
|
|
|
... on UpdateHighlightError {
|
|
errorCodes
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
try {
|
|
const data = await gqlFetcher(mutation, { input })
|
|
const output = data as UpdateHighlightOutput | undefined
|
|
return output?.updateHighlight.highlight.id
|
|
} catch {
|
|
return undefined
|
|
}
|
|
}
|