Files
omnivore/packages/web/lib/networking/mutations/updateUserProfileMutation.ts
Jackson Harper 34e9ed16b5 Add settings menu
2023-09-30 12:51:15 +08:00

41 lines
936 B
TypeScript

import { gql } from 'graphql-request'
import { gqlFetcher } from '../networkHelpers'
import { State } from '../fragments/articleFragment'
export type UpdateUserProfileInput = {
userId: string
username: string
}
export async function updateUserProfileMutation(
input: UpdateUserProfileInput
): Promise<string | undefined> {
const mutation = gql`
mutation UpdateUserProfile($input: UpdateUserProfileInput!) {
updateUserProfile(input: $input) {
... on UpdateUserProfileSuccess {
user {
profile {
username
}
}
}
... on UpdateUserProfileError {
errorCodes
}
}
}
`
try {
const data = await gqlFetcher(mutation, {
input,
})
const output = data as any
console.log('output: ', output)
return output.updateUserProfile.user.profile.username
} catch (err) {
return undefined
}
}