debian-mirror-gitlab/app/assets/javascripts/clusters/agents/graphql/cache_update.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
618 B
JavaScript
Raw Normal View History

2022-05-07 20:08:51 +05:30
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,
});
}
}