blob: 0219c4150ebbf88fdda88de67eca6af8c3895bf9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import produce from 'immer';
export const hasErrors = ({ errors = [] }) => errors?.length;
export function addAgentTokenToStore(store, clusterAgentTokenCreate, query, variables) {
if (!hasErrors(clusterAgentTokenCreate)) {
const { token } = clusterAgentTokenCreate;
const sourceData = store.readQuery({
query,
variables,
});
const data = produce(sourceData, (draftData) => {
draftData.project.clusterAgent.tokens.nodes.unshift(token);
draftData.project.clusterAgent.tokens.count += 1;
});
store.writeQuery({
query,
variables,
data,
});
}
}
|