• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kiva / ui / 23517001991

24 Mar 2026 11:22PM UTC coverage: 87.113% (-0.04%) from 87.149%
23517001991

push

github

web-flow
Merge pull request #6771 from kiva/feature/mp-2469-use-setMyKivaGoal-mutation

feat: [MP-2469] - use setMyKivaGoal mutation on GoalData composable

4619 of 5050 branches covered (91.47%)

Branch coverage included in aggregate %.

50 of 75 new or added lines in 6 files covered. (66.67%)

1 existing line in 1 file now uncovered.

35387 of 40874 relevant lines covered (86.58%)

41.64 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.63
/src/util/userPreferenceUtils.js
1
import { gql } from 'graphql-tag';
1✔
2
import setMyKivaGoalMutation from '#src/graphql/mutation/accountSettings/setMyKivaGoal.graphql';
1✔
3
import logReadQueryError from './logReadQueryError';
1✔
4

5
export const createUserPreferencesMutation = gql`
1✔
6
        mutation createUserPreferences($preferences: String) {
1✔
7
                my {
1✔
8
                        createUserPreferences(userPreferences: { preferences: $preferences }) {
1✔
9
                                id
1✔
10
                                preferences
1✔
11
                        }
1✔
12
                }
1✔
13
        }
1✔
14
`;
1✔
15

16
export const updateUserPreferencesMutation = gql`
1✔
17
        mutation UpdateUserPreferences(
1✔
18
                $updateUserPreferencesId: Int!,
1✔
19
                $preferences: String
1✔
20
        ) {
1✔
21
                my {
1✔
22
                        updateUserPreferences(id: $updateUserPreferencesId, userPreferences: {
1✔
23
                                preferences: $preferences
1✔
24
                }) {
1✔
25
                                id
1✔
26
                                preferences
1✔
27
                        }
1✔
28
                }
1✔
29
        }
1✔
30
`;
1✔
31

32
/**
1✔
33
 * Creates user preferences for the current user
1✔
34
 *
1✔
35
 * @param apollo The current Apollo client
1✔
36
 * @param newPreferences The new preferences to add
1✔
37
 * @returns The results of the mutation
1✔
38
 */
1✔
39
export const createUserPreferences = async (apollo, newPreferences) => {
1✔
40
        try {
2✔
41
                return await apollo.mutate({
2✔
42
                        mutation: createUserPreferencesMutation,
2✔
43
                        variables: { preferences: JSON.stringify(newPreferences) },
2✔
44
                });
2✔
45
        } catch (e) {
2✔
46
                logReadQueryError(e, 'userPreferenceUtils createUserPreferencesMutation');
1✔
47
        }
1✔
48
};
2✔
49

50
/**
1✔
51
 * Updates the user preferences for the current user
1✔
52
 *
1✔
53
 * @param apollo The current Apollo client
1✔
54
 * @param userPreferences The original user preferences
1✔
55
 * @param parsedPreferences The parsed user preferences
1✔
56
 * @param newPreferences The new preferences to add
1✔
57
 * @returns The updated user preferences
1✔
58
 */
1✔
59
export const updateUserPreferences = async (apollo, userPreferences, parsedPreferences, newPreferences) => {
1✔
60
        try {
2✔
61
                const mergedPreferences = { ...parsedPreferences, ...newPreferences };
2✔
62
                const preferences = JSON.stringify(mergedPreferences);
2✔
63
                return await apollo.mutate({
2✔
64
                        mutation: updateUserPreferencesMutation,
2✔
65
                        variables: {
2✔
66
                                updateUserPreferencesId: userPreferences.id,
2✔
67
                                preferences,
2✔
68
                        },
2✔
69
                });
2✔
70
        } catch (e) {
2✔
71
                logReadQueryError(e, 'userPreferenceUtils updateUserPreferencesMutation');
1✔
72
        }
1✔
73
};
2✔
74

75
/**
1✔
76
 * Set a My Kiva goal using the setMyKivaGoal mutation
1✔
77
 *
1✔
78
 * @param apollo The current Apollo client
1✔
79
 * @param {Object} goalData The goal data to upsert
1✔
80
 * @param {string} goalData.category The goal category
1✔
81
 * @param {number} goalData.target The target number of loans
1✔
82
 * @param {string} goalData.dateStarted The date the goal was started (ISO-8601)
1✔
83
 * @param {string} goalData.status The goal status
1✔
84
 * @returns The result of the mutation
1✔
85
 */
1✔
86
export const setMyKivaGoal = async (apollo, {
1✔
NEW
87
        category, target, dateStarted, status
×
NEW
88
}) => {
×
NEW
89
        return apollo.mutate({
×
NEW
90
                mutation: setMyKivaGoalMutation,
×
NEW
91
                variables: {
×
NEW
92
                        category,
×
NEW
93
                        target,
×
NEW
94
                        dateStarted,
×
NEW
95
                        status,
×
NEW
96
                },
×
NEW
97
        });
×
NEW
98
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc