Skip to content

Commit b550590

Browse files
committed
fix(tags): switch out legacy mutations
1 parent f71fef2 commit b550590

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { gql } from 'common/utilities/gql/gql'
2+
import { requestGQL } from 'common/utilities/request/request'
3+
4+
const renameTagQuery = gql`
5+
mutation RenameTagByName($oldName: String!, $newName: String!) {
6+
renameTagByName(oldName: $oldName, newName: $newName) {
7+
name
8+
id
9+
}
10+
}
11+
`
12+
13+
export function renameTag({ oldName, newName }: { oldName: string; newName: string }) {
14+
return requestGQL({
15+
query: renameTagQuery,
16+
variables: { oldName, newName }
17+
})
18+
.then((response) => {
19+
const { name, id } = response?.data?.renameTagByName
20+
return { name, id }
21+
})
22+
.catch((error) => console.error(error))
23+
}
24+
25+
const deleteTagQuery = gql`
26+
mutation deleteTag($tagName: String!) {
27+
deleteTagByName(tagName: $tagName)
28+
}
29+
`
30+
31+
export function deleteTag(tagName: string) {
32+
return requestGQL({
33+
query: deleteTagQuery,
34+
variables: { tagName }
35+
})
36+
.then((response) => {
37+
const deletedTag = response?.data?.deleteTagByName
38+
return { deletedTag }
39+
})
40+
.catch((error) => console.error(error))
41+
}

clients/web/src/common/utilities/request/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const postMime = ({ api_url = API_URL, params = {}, path, method = 'POST'
121121
*
122122
* @param {Object} data
123123
* @param {string} data.query Query to execute on the graph
124-
* @param {string} data.operationName Basic name to help identify the request (testing, logging)
124+
* @param {string} [data.operationName] Basic name to help identify the request (testing, logging)
125125
* @param {object} data.variables Variables to use when interpolatin the query
126126
**/
127127
export const requestGQL = (data) => {

clients/web/src/containers/saves/tagged/tagged-page.state.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { put, call, takeEvery, select } from 'redux-saga/effects'
2-
import { renameStoredTag } from 'common/api/_legacy/tags'
3-
import { deleteStoredTag } from 'common/api/_legacy/tags'
2+
import { renameTag, deleteTag } from 'common/api/mutations/tags'
43
import { getUserTags as getUserTagsGraph } from 'common/api/queries/get-user-tags'
54

65
import { USER_TAGS_PIN } from 'actions'
@@ -147,7 +146,7 @@ function* userTagsTogglePin(actions) {
147146

148147
function* userTagsEditConfirm(action) {
149148
const { new_tag, old_tag, router } = action
150-
const data = yield call(renameStoredTag, { new_tag, old_tag })
149+
const data = yield call(renameTag, { oldName: old_tag, newName: new_tag })
151150

152151
if (data) {
153152
const pinnedItems = yield select(getPinnedTags)
@@ -161,7 +160,7 @@ function* userTagsEditConfirm(action) {
161160

162161
function* userTagsDeleteConfirm(action) {
163162
const { tag, router } = action
164-
const data = yield call(deleteStoredTag, tag)
163+
const data = yield call(deleteTag, tag)
165164

166165
if (data) {
167166
const pinnedItems = yield select(getPinnedTags)

0 commit comments

Comments
 (0)