debian-mirror-gitlab/app/assets/javascripts/terraform/graphql/resolvers.js

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

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import TerraformState from './fragments/state.fragment.graphql';
export default {
TerraformState: {
_showDetails: (state) => {
// eslint-disable-next-line no-underscore-dangle
return state._showDetails || false;
},
errorMessages: (state) => {
return state.errorMessages || [];
},
loadingLock: (state) => {
return state.loadingLock || false;
},
loadingRemove: (state) => {
return state.loadingRemove || false;
},
},
Mutation: {
addDataToTerraformState: (_, { terraformState }, { client }) => {
const fragmentData = {
id: terraformState.id,
fragment: TerraformState,
// eslint-disable-next-line @gitlab/require-i18n-strings
fragmentName: 'State',
};
const previousTerraformState = client.readFragment(fragmentData);
if (previousTerraformState) {
client.writeFragment({
...fragmentData,
data: {
...previousTerraformState,
// eslint-disable-next-line no-underscore-dangle
_showDetails: terraformState._showDetails,
errorMessages: terraformState.errorMessages,
loadingLock: terraformState.loadingLock,
loadingRemove: terraformState.loadingRemove,
},
});
}
},
},
};