Commit 21b5902d authored by Frederic Caplette's avatar Frederic Caplette

Update lint query with connections and let editor handle unwrapping

We are reverting the lint query back to using connections
so that we can have more flexibility and coherenec on the FE. We
also let apollo handle the unwrapping of the nodes so that all
children components can know their data is already in the right format.
parent 1cc701d2
#import "~/pipelines/graphql/queries/pipeline_stages.fragment.graphql" #import "~/pipelines/graphql/queries/pipeline_stages_connection.fragment.graphql"
query getCiConfigData($content: String!) { query getCiConfigData($content: String!) {
ciConfig(content: $content) { ciConfig(content: $content) {
errors errors
status status
stages { stages {
...PipelineStagesData ...PipelineStagesConnection
} }
} }
} }
...@@ -10,6 +10,7 @@ import TextEditor from './components/text_editor.vue'; ...@@ -10,6 +10,7 @@ import TextEditor from './components/text_editor.vue';
import commitCiFileMutation from './graphql/mutations/commit_ci_file.mutation.graphql'; import commitCiFileMutation from './graphql/mutations/commit_ci_file.mutation.graphql';
import getBlobContent from './graphql/queries/blob_content.graphql'; import getBlobContent from './graphql/queries/blob_content.graphql';
import getCiConfigData from './graphql/queries/ci_config.graphql'; import getCiConfigData from './graphql/queries/ci_config.graphql';
import { unwrapStagesWithNeeds } from '~/pipelines/components/unwrapping_utils';
const MR_SOURCE_BRANCH = 'merge_request[source_branch]'; const MR_SOURCE_BRANCH = 'merge_request[source_branch]';
const MR_TARGET_BRANCH = 'merge_request[target_branch]'; const MR_TARGET_BRANCH = 'merge_request[target_branch]';
...@@ -99,7 +100,11 @@ export default { ...@@ -99,7 +100,11 @@ export default {
}; };
}, },
update(data) { update(data) {
return data?.ciConfig ?? {}; const { ciConfigData } = data || {};
const stageNodes = ciConfigData?.stages?.nodes || [];
const stages = unwrapStagesWithNeeds(stageNodes);
return { ...ciConfigData, stages };
}, },
error() { error() {
this.reportFailure(LOAD_FAILURE_UNKNOWN); this.reportFailure(LOAD_FAILURE_UNKNOWN);
......
fragment PipelineStagesData on CiConfigStage {
name
groups {
name
jobs {
name
needs {
name
}
}
}
}
fragment PipelineStagesConnection on CiConfigStageConnection {
nodes {
name
groups {
nodes {
name
jobs {
nodes {
name
needs {
nodes {
name
}
}
}
}
}
}
}
}
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