Commit 5020ec91 authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '32085-fe-improve-documentation-and-static-checks-regarding-mutation-errors-conventions' into 'master'

Ensure all mutations have 'errors' field and a proper handler

See merge request gitlab-org/gitlab!27328
parents 77885f3a 9850207b
mutation ($projectPath: ID!, $iid: String!, $healthStatus: HealthStatus) {
updateIssue(input: { projectPath: $projectPath, iid: $iid, healthStatus: $healthStatus}) {
mutation($projectPath: ID!, $iid: String!, $healthStatus: HealthStatus) {
updateIssue(input: { projectPath: $projectPath, iid: $iid, healthStatus: $healthStatus }) {
issue {
healthStatus
}
errors
}
}
......@@ -137,7 +137,10 @@ export default {
mutation: DeleteSnippetMutation,
variables: { id: this.snippet.id },
})
.then(() => {
.then(({ data }) => {
if (data?.destroySnippet?.errors) {
throw new Error(data?.destroySnippet?.errors[0]);
}
this.isDeleting = false;
this.errorMessage = undefined;
this.closeDeleteModal();
......
......@@ -33,7 +33,12 @@ export default class SidebarMediator extends CESidebarMediator {
this.store.setFetchingState('status', true);
return this.service
.updateWithGraphQl(updateStatusMutation, { healthStatus })
.then(({ data }) => this.store.setStatus(data?.updateIssue?.issue?.healthStatus))
.then(({ data }) => {
if (data?.updateIssue?.errors?.length > 0) {
throw data.updateIssue.errors[0];
}
this.store.setStatus(data?.updateIssue?.issue?.healthStatus);
})
.catch(error => {
throw error;
})
......
......@@ -32,7 +32,7 @@ describe('Snippet header component', () => {
const errorMsg = 'Foo bar';
const err = { message: errorMsg };
const resolveMutate = jest.fn(() => Promise.resolve());
const resolveMutate = jest.fn(() => Promise.resolve({ data: {} }));
const rejectMutation = jest.fn(() => Promise.reject(err));
const mutationTypes = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment