add create label gql mutation

This commit is contained in:
Satindar Dhillon 2023-03-07 20:41:15 -08:00
parent fa97d01d0c
commit b5a65cbc91
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,16 @@
mutation CreateLabel($input: CreateLabelInput!) {
createLabel(input: $input) {
... on CreateLabelSuccess {
label {
id
name
color
description
createdAt
}
}
... on CreateLabelError {
errorCodes
}
}
}

View file

@ -1,6 +1,8 @@
package app.omnivore.omnivore.networking
import app.omnivore.omnivore.graphql.generated.CreateLabelMutation
import app.omnivore.omnivore.graphql.generated.SetLabelsMutation
import app.omnivore.omnivore.graphql.generated.type.CreateLabelInput
import app.omnivore.omnivore.graphql.generated.type.SetLabelsInput
suspend fun Networker.updateLabelsForSavedItem(input: SetLabelsInput): Boolean {
@ -11,3 +13,12 @@ suspend fun Networker.updateLabelsForSavedItem(input: SetLabelsInput): Boolean {
false
}
}
suspend fun Networker.createNewLabel(input: CreateLabelInput): CreateLabelMutation.Label? {
return try {
val result = authenticatedApolloClient().mutation(CreateLabelMutation(input)).execute()
return result.data?.createLabel?.onCreateLabelSuccess?.label
} catch (e: java.lang.Exception) {
null
}
}