Commit 044c876f authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'cngo-extract-graphql-types-to-constants' into 'master'

Extract GraphQL string literal types to constants

See merge request gitlab-org/gitlab!65065
parents 0e7aa6fc 5711632d
<script> <script>
import { GlIcon, GlLink, GlPopover, GlLoadingIcon } from '@gitlab/ui'; import { GlIcon, GlLink, GlPopover, GlLoadingIcon } from '@gitlab/ui';
import { blockingIssuablesQueries, issuableTypes } from '~/boards/constants'; import { blockingIssuablesQueries, issuableTypes } from '~/boards/constants';
import { IssueType } from '~/graphql_shared/constants'; import { TYPE_ISSUE } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { truncate } from '~/lib/utils/text_utility'; import { truncate } from '~/lib/utils/text_utility';
import { __, n__, s__, sprintf } from '~/locale'; import { __, n__, s__, sprintf } from '~/locale';
...@@ -13,7 +13,7 @@ export default { ...@@ -13,7 +13,7 @@ export default {
}, },
}, },
graphQLIdType: { graphQLIdType: {
[issuableTypes.issue]: IssueType, [issuableTypes.issue]: TYPE_ISSUE,
}, },
referenceFormatter: { referenceFormatter: {
[issuableTypes.issue]: (r) => r.split('/')[1], [issuableTypes.issue]: (r) => r.split('/')[1],
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import { GlModal, GlAlert } from '@gitlab/ui'; import { GlModal, GlAlert } from '@gitlab/ui';
import { mapGetters, mapActions, mapState } from 'vuex'; import { mapGetters, mapActions, mapState } from 'vuex';
import ListLabel from '~/boards/models/label'; import ListLabel from '~/boards/models/label';
import { TYPE_ITERATION, TYPE_MILESTONE, TYPE_USER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { getParameterByName } from '~/lib/utils/common_utils'; import { getParameterByName } from '~/lib/utils/common_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -188,21 +189,19 @@ export default { ...@@ -188,21 +189,19 @@ export default {
}; };
}, },
issueBoardScopeMutationVariables() { issueBoardScopeMutationVariables() {
/* eslint-disable @gitlab/require-i18n-strings */
return { return {
weight: this.board.weight, weight: this.board.weight,
assigneeId: this.board.assignee?.id assigneeId: this.board.assignee?.id
? convertToGraphQLId('User', this.board.assignee.id) ? convertToGraphQLId(TYPE_USER, this.board.assignee.id)
: null, : null,
milestoneId: milestoneId:
this.board.milestone?.id || this.board.milestone?.id === 0 this.board.milestone?.id || this.board.milestone?.id === 0
? convertToGraphQLId('Milestone', this.board.milestone.id) ? convertToGraphQLId(TYPE_MILESTONE, this.board.milestone.id)
: null, : null,
iterationId: this.board.iteration_id iterationId: this.board.iteration_id
? convertToGraphQLId('Iteration', this.board.iteration_id) ? convertToGraphQLId(TYPE_ITERATION, this.board.iteration_id)
: null, : null,
}; };
/* eslint-enable @gitlab/require-i18n-strings */
}, },
boardScopeMutationVariables() { boardScopeMutationVariables() {
return { return {
......
/* eslint-disable @gitlab/require-i18n-strings */ export const TYPE_CI_RUNNER = 'Ci::Runner';
export const IssueType = 'Issue'; export const TYPE_GROUP = 'Group';
export const TYPE_ISSUE = 'Issue';
export const TYPE_ITERATION = 'Iteration';
export const TYPE_ITERATIONS_CADENCE = 'Iterations::Cadence';
export const TYPE_MERGE_REQUEST = 'MergeRequest';
export const TYPE_MILESTONE = 'Milestone';
export const TYPE_SCANNER_PROFILE = 'DastScannerProfile';
export const TYPE_SITE_PROFILE = 'DastSiteProfile';
export const TYPE_USER = 'User';
export const TYPE_VULNERABILITY = 'Vulnerability';
...@@ -17,11 +17,6 @@ export const MutationOperationMode = { ...@@ -17,11 +17,6 @@ export const MutationOperationMode = {
Replace: 'REPLACE', Replace: 'REPLACE',
}; };
/**
* Possible GraphQL entity types.
*/
export const TYPE_GROUP = 'Group';
/** /**
* Ids generated by GraphQL endpoints are usually in the format * Ids generated by GraphQL endpoints are usually in the format
* gid://gitlab/Groups/123. This method takes a type and an id * gid://gitlab/Groups/123. This method takes a type and an id
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
import fuzzaldrinPlus from 'fuzzaldrin-plus'; import fuzzaldrinPlus from 'fuzzaldrin-plus';
import getIssuesQuery from 'ee_else_ce/issues_list/queries/get_issues.query.graphql'; import getIssuesQuery from 'ee_else_ce/issues_list/queries/get_issues.query.graphql';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { TYPE_USER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import CsvImportExportButtons from '~/issuable/components/csv_import_export_buttons.vue'; import CsvImportExportButtons from '~/issuable/components/csv_import_export_buttons.vue';
import IssuableByEmail from '~/issuable/components/issuable_by_email.vue'; import IssuableByEmail from '~/issuable/components/issuable_by_email.vue';
...@@ -268,7 +269,7 @@ export default { ...@@ -268,7 +269,7 @@ export default {
if (gon.current_user_id) { if (gon.current_user_id) {
preloadedAuthors.push({ preloadedAuthors.push({
id: convertToGraphQLId('User', gon.current_user_id), // eslint-disable-line @gitlab/require-i18n-strings id: convertToGraphQLId(TYPE_USER, gon.current_user_id),
name: gon.current_user_fullname, name: gon.current_user_fullname,
username: gon.current_username, username: gon.current_username,
avatar_url: gon.current_user_avatar_url, avatar_url: gon.current_user_avatar_url,
......
...@@ -4,8 +4,6 @@ export const RUNNER_PAGE_SIZE = 20; ...@@ -4,8 +4,6 @@ export const RUNNER_PAGE_SIZE = 20;
export const I18N_DETAILS_TITLE = s__('Runners|Runner #%{runner_id}'); export const I18N_DETAILS_TITLE = s__('Runners|Runner #%{runner_id}');
export const RUNNER_ENTITY_TYPE = 'Ci::Runner';
export const RUNNER_TAG_BADGE_VARIANT = 'info'; export const RUNNER_TAG_BADGE_VARIANT = 'info';
export const RUNNER_TAG_BG_CLASS = 'gl-bg-blue-100'; export const RUNNER_TAG_BG_CLASS = 'gl-bg-blue-100';
......
<script> <script>
import { TYPE_CI_RUNNER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import RunnerTypeAlert from '../components/runner_type_alert.vue'; import RunnerTypeAlert from '../components/runner_type_alert.vue';
import RunnerTypeBadge from '../components/runner_type_badge.vue'; import RunnerTypeBadge from '../components/runner_type_badge.vue';
import RunnerUpdateForm from '../components/runner_update_form.vue'; import RunnerUpdateForm from '../components/runner_update_form.vue';
import { I18N_DETAILS_TITLE, RUNNER_ENTITY_TYPE } from '../constants'; import { I18N_DETAILS_TITLE } from '../constants';
import getRunnerQuery from '../graphql/get_runner.query.graphql'; import getRunnerQuery from '../graphql/get_runner.query.graphql';
export default { export default {
...@@ -31,7 +32,7 @@ export default { ...@@ -31,7 +32,7 @@ export default {
query: getRunnerQuery, query: getRunnerQuery,
variables() { variables() {
return { return {
id: convertToGraphQLId(RUNNER_ENTITY_TYPE, this.runnerId), id: convertToGraphQLId(TYPE_CI_RUNNER, this.runnerId),
}; };
}, },
}, },
......
<script> <script>
import { GlLoadingIcon, GlTable } from '@gitlab/ui'; import { GlLoadingIcon, GlTable } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { TYPE_ISSUE, TYPE_MERGE_REQUEST } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { formatDate, parseSeconds, stringifyTime } from '~/lib/utils/datetime_utility'; import { formatDate, parseSeconds, stringifyTime } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -52,8 +53,7 @@ export default { ...@@ -52,8 +53,7 @@ export default {
return this.issuableType === 'issue'; return this.issuableType === 'issue';
}, },
getGraphQLEntityType() { getGraphQLEntityType() {
// eslint-disable-next-line @gitlab/require-i18n-strings return this.isIssue() ? TYPE_ISSUE : TYPE_MERGE_REQUEST;
return this.isIssue() ? 'Issue' : 'MergeRequest';
}, },
extractTimelogs(data) { extractTimelogs(data) {
const timelogs = data?.issuable?.timelogs?.nodes || []; const timelogs = data?.issuable?.timelogs?.nodes || [];
......
import sidebarDetailsIssueQuery from 'ee_else_ce/sidebar/queries/sidebarDetails.query.graphql'; import sidebarDetailsIssueQuery from 'ee_else_ce/sidebar/queries/sidebarDetails.query.graphql';
import { TYPE_USER } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import createGqClient, { fetchPolicies } from '~/lib/graphql'; import createGqClient, { fetchPolicies } from '~/lib/graphql';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -88,7 +89,7 @@ export default class SidebarService { ...@@ -88,7 +89,7 @@ export default class SidebarService {
return gqClient.mutate({ return gqClient.mutate({
mutation: reviewerRereviewMutation, mutation: reviewerRereviewMutation,
variables: { variables: {
userId: convertToGraphQLId('User', `${userId}`), // eslint-disable-line @gitlab/require-i18n-strings userId: convertToGraphQLId(TYPE_USER, `${userId}`),
projectPath: this.fullPath, projectPath: this.fullPath,
iid: this.iid.toString(), iid: this.iid.toString(),
}, },
......
...@@ -7,7 +7,8 @@ import { ...@@ -7,7 +7,8 @@ import {
GlTooltipDirective, GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { convertToGraphQLId, TYPE_GROUP } from '~/graphql_shared/utils'; import { TYPE_GROUP } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import { import {
DEBOUNCE_DELAY, DEBOUNCE_DELAY,
DEVOPS_ADOPTION_GROUP_DROPDOWN_TEXT, DEVOPS_ADOPTION_GROUP_DROPDOWN_TEXT,
......
import Vue from 'vue'; import Vue from 'vue';
import { convertToGraphQLId, TYPE_GROUP } from '~/graphql_shared/utils'; import { TYPE_GROUP } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
import DevopsAdoptionApp from './components/devops_adoption_app.vue'; import DevopsAdoptionApp from './components/devops_adoption_app.vue';
import { createApolloProvider } from './graphql'; import { createApolloProvider } from './graphql';
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
GlFormSelect, GlFormSelect,
GlFormTextarea, GlFormTextarea,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { TYPE_ITERATIONS_CADENCE } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import createCadence from '../queries/cadence_create.mutation.graphql'; import createCadence from '../queries/cadence_create.mutation.graphql';
...@@ -130,7 +131,7 @@ export default { ...@@ -130,7 +131,7 @@ export default {
}, },
variables() { variables() {
const id = this.isEdit const id = this.isEdit
? convertToGraphQLId('Iterations::Cadence', this.cadenceId) ? convertToGraphQLId(TYPE_ITERATIONS_CADENCE, this.cadenceId)
: undefined; : undefined;
const groupPath = this.isEdit ? undefined : this.groupPath; const groupPath = this.isEdit ? undefined : this.groupPath;
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
GlLoadingIcon, GlLoadingIcon,
} from '@gitlab/ui'; } from '@gitlab/ui';
import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue'; import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue';
import { TYPE_ITERATION } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -39,15 +40,13 @@ export default { ...@@ -39,15 +40,13 @@ export default {
apollo: { apollo: {
iteration: { iteration: {
query, query,
/* eslint-disable @gitlab/require-i18n-strings */
variables() { variables() {
return { return {
fullPath: this.fullPath, fullPath: this.fullPath,
id: convertToGraphQLId('Iteration', this.iterationId), id: convertToGraphQLId(TYPE_ITERATION, this.iterationId),
isGroup: this.namespaceType === Namespace.Group, isGroup: this.namespaceType === Namespace.Group,
}; };
}, },
/* eslint-enable @gitlab/require-i18n-strings */
update(data) { update(data) {
return data[this.namespaceType]?.iterations?.nodes[0] || {}; return data[this.namespaceType]?.iterations?.nodes[0] || {};
}, },
......
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
GlLoadingIcon, GlLoadingIcon,
} from '@gitlab/ui'; } from '@gitlab/ui';
import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue'; import BurnCharts from 'ee/burndown_chart/components/burn_charts.vue';
import { TYPE_ITERATION } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -46,15 +47,13 @@ export default { ...@@ -46,15 +47,13 @@ export default {
apollo: { apollo: {
iteration: { iteration: {
query, query,
/* eslint-disable @gitlab/require-i18n-strings */
variables() { variables() {
return { return {
fullPath: this.fullPath, fullPath: this.fullPath,
id: convertToGraphQLId('Iteration', this.iterationId), id: convertToGraphQLId(TYPE_ITERATION, this.iterationId),
isGroup: this.namespaceType === Namespace.Group, isGroup: this.namespaceType === Namespace.Group,
}; };
}, },
/* eslint-enable @gitlab/require-i18n-strings */
update(data) { update(data) {
return data[this.namespaceType]?.iterations?.nodes[0] || {}; return data[this.namespaceType]?.iterations?.nodes[0] || {};
}, },
......
...@@ -17,6 +17,7 @@ import * as Sentry from '@sentry/browser'; ...@@ -17,6 +17,7 @@ import * as Sentry from '@sentry/browser';
import { SCAN_TYPE } from 'ee/security_configuration/dast_scanner_profiles/constants'; import { SCAN_TYPE } from 'ee/security_configuration/dast_scanner_profiles/constants';
import { DAST_SITE_VALIDATION_STATUS } from 'ee/security_configuration/dast_site_validation/constants'; import { DAST_SITE_VALIDATION_STATUS } from 'ee/security_configuration/dast_site_validation/constants';
import { initFormField } from 'ee/security_configuration/utils'; import { initFormField } from 'ee/security_configuration/utils';
import { TYPE_SCANNER_PROFILE, TYPE_SITE_PROFILE } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { serializeFormObject } from '~/lib/utils/forms'; import { serializeFormObject } from '~/lib/utils/forms';
import { redirectTo, queryToObject } from '~/lib/utils/url_utility'; import { redirectTo, queryToObject } from '~/lib/utils/url_utility';
...@@ -34,8 +35,6 @@ import { ...@@ -34,8 +35,6 @@ import {
ERROR_MESSAGES, ERROR_MESSAGES,
SCANNER_PROFILES_QUERY, SCANNER_PROFILES_QUERY,
SITE_PROFILES_QUERY, SITE_PROFILES_QUERY,
TYPE_SITE_PROFILE,
TYPE_SCANNER_PROFILE,
} from '../settings'; } from '../settings';
import ScannerProfileSelector from './profile_selector/scanner_profile_selector.vue'; import ScannerProfileSelector from './profile_selector/scanner_profile_selector.vue';
import SiteProfileSelector from './profile_selector/site_profile_selector.vue'; import SiteProfileSelector from './profile_selector/site_profile_selector.vue';
......
...@@ -27,6 +27,3 @@ export const SITE_PROFILES_QUERY = { ...@@ -27,6 +27,3 @@ export const SITE_PROFILES_QUERY = {
fetchQuery: dastSiteProfilesQuery, fetchQuery: dastSiteProfilesQuery,
fetchError: ERROR_FETCH_SITE_PROFILES, fetchError: ERROR_FETCH_SITE_PROFILES,
}; };
export const TYPE_SITE_PROFILE = 'DastSiteProfile';
export const TYPE_SCANNER_PROFILE = 'DastScannerProfile';
<script> <script>
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import vulnerabilityExternalIssueLinkCreate from 'ee/vue_shared/security_reports/graphql/vulnerabilityExternalIssueLinkCreate.mutation.graphql'; import vulnerabilityExternalIssueLinkCreate from 'ee/vue_shared/security_reports/graphql/vulnerabilityExternalIssueLinkCreate.mutation.graphql';
import { TYPE_VULNERABILITY } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -33,18 +34,17 @@ export default { ...@@ -33,18 +34,17 @@ export default {
async createJiraIssue() { async createJiraIssue() {
this.isLoading = true; this.isLoading = true;
try { try {
/* eslint-disable @gitlab/require-i18n-strings */
const { data } = await this.$apollo.mutate({ const { data } = await this.$apollo.mutate({
mutation: vulnerabilityExternalIssueLinkCreate, mutation: vulnerabilityExternalIssueLinkCreate,
variables: { variables: {
input: { input: {
externalTracker: 'JIRA', externalTracker: 'JIRA',
linkType: 'CREATED', linkType: 'CREATED',
id: convertToGraphQLId('Vulnerability', this.vulnerabilityId), id: convertToGraphQLId(TYPE_VULNERABILITY, this.vulnerabilityId),
}, },
}, },
}); });
/* eslint-enable @gitlab/require-i18n-strings */
const { errors } = data.vulnerabilityExternalIssueLinkCreate; const { errors } = data.vulnerabilityExternalIssueLinkCreate;
if (errors.length > 0) { if (errors.length > 0) {
......
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