diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/assets/javascripts/terraform/graphql/resolvers.js | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/assets/javascripts/terraform/graphql/resolvers.js')
-rw-r--r-- | app/assets/javascripts/terraform/graphql/resolvers.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/assets/javascripts/terraform/graphql/resolvers.js b/app/assets/javascripts/terraform/graphql/resolvers.js new file mode 100644 index 00000000000..d27379bdd9f --- /dev/null +++ b/app/assets/javascripts/terraform/graphql/resolvers.js @@ -0,0 +1,45 @@ +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, + }, + }); + } + }, + }, +}; |