diff options
Diffstat (limited to 'app/assets/javascripts/ci_variable_list/graphql')
16 files changed, 0 insertions, 539 deletions
diff --git a/app/assets/javascripts/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql b/app/assets/javascripts/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql deleted file mode 100644 index a28ca4eebc9..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql +++ /dev/null @@ -1,7 +0,0 @@ -fragment BaseCiVariable on CiVariable { - __typename - id - key - value - variableType -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_add_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_add_variable.mutation.graphql deleted file mode 100644 index 9208c34f154..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_add_variable.mutation.graphql +++ /dev/null @@ -1,16 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation addAdminVariable($variable: CiVariable!, $endpoint: String!) { - ciVariableMutation: addAdminVariable(variable: $variable, endpoint: $endpoint) @client { - ciVariables { - nodes { - ...BaseCiVariable - ... on CiInstanceVariable { - protected - masked - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_delete_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_delete_variable.mutation.graphql deleted file mode 100644 index a79b98f5e95..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_delete_variable.mutation.graphql +++ /dev/null @@ -1,16 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation deleteAdminVariable($variable: CiVariable!, $endpoint: String!) { - ciVariableMutation: deleteAdminVariable(variable: $variable, endpoint: $endpoint) @client { - ciVariables { - nodes { - ...BaseCiVariable - ... on CiInstanceVariable { - protected - masked - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_update_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_update_variable.mutation.graphql deleted file mode 100644 index ddea753bf90..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/admin_update_variable.mutation.graphql +++ /dev/null @@ -1,16 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation updateAdminVariable($variable: CiVariable!, $endpoint: String!) { - ciVariableMutation: updateAdminVariable(variable: $variable, endpoint: $endpoint) @client { - ciVariables { - nodes { - ...BaseCiVariable - ... on CiInstanceVariable { - protected - masked - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/client/add_project_environment.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/client/add_project_environment.mutation.graphql deleted file mode 100644 index 45109762e80..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/client/add_project_environment.mutation.graphql +++ /dev/null @@ -1,3 +0,0 @@ -mutation addProjectEnvironment($environment: CiEnvironment, $fullPath: ID!) { - addProjectEnvironment(environment: $environment, fullPath: $fullPath) @client -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/group_add_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/group_add_variable.mutation.graphql deleted file mode 100644 index 24388637672..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/group_add_variable.mutation.graphql +++ /dev/null @@ -1,26 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation addGroupVariable($variable: CiVariable!, $endpoint: String!, $fullPath: ID!, $id: ID!) { - ciVariableMutation: addGroupVariable( - variable: $variable - endpoint: $endpoint - fullPath: $fullPath - id: $id - ) @client { - group { - id - ciVariables { - nodes { - ...BaseCiVariable - ... on CiGroupVariable { - environmentScope - masked - protected - raw - } - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/group_delete_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/group_delete_variable.mutation.graphql deleted file mode 100644 index f7c8e209ccd..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/group_delete_variable.mutation.graphql +++ /dev/null @@ -1,26 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation deleteGroupVariable($variable: CiVariable!, $endpoint: String!, $fullPath: ID!, $id: ID!) { - ciVariableMutation: deleteGroupVariable( - variable: $variable - endpoint: $endpoint - fullPath: $fullPath - id: $id - ) @client { - group { - id - ciVariables { - nodes { - ...BaseCiVariable - ... on CiGroupVariable { - environmentScope - masked - protected - raw - } - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/group_update_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/group_update_variable.mutation.graphql deleted file mode 100644 index 757e61a5cd3..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/group_update_variable.mutation.graphql +++ /dev/null @@ -1,26 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation updateGroupVariable($variable: CiVariable!, $endpoint: String!, $fullPath: ID!, $id: ID!) { - ciVariableMutation: updateGroupVariable( - variable: $variable - endpoint: $endpoint - fullPath: $fullPath - id: $id - ) @client { - group { - id - ciVariables { - nodes { - ...BaseCiVariable - ... on CiGroupVariable { - environmentScope - masked - protected - raw - } - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/project_add_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/project_add_variable.mutation.graphql deleted file mode 100644 index fa315084d86..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/project_add_variable.mutation.graphql +++ /dev/null @@ -1,26 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation addProjectVariable($variable: CiVariable!, $endpoint: String!, $fullPath: ID!, $id: ID!) { - ciVariableMutation: addProjectVariable( - variable: $variable - endpoint: $endpoint - fullPath: $fullPath - id: $id - ) @client { - project { - id - ciVariables { - nodes { - ...BaseCiVariable - ... on CiProjectVariable { - environmentScope - masked - protected - raw - } - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/project_delete_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/project_delete_variable.mutation.graphql deleted file mode 100644 index c3358cc35b9..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/project_delete_variable.mutation.graphql +++ /dev/null @@ -1,31 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation deleteProjectVariable( - $variable: CiVariable! - $endpoint: String! - $fullPath: ID! - $id: ID! -) { - ciVariableMutation: deleteProjectVariable( - variable: $variable - endpoint: $endpoint - fullPath: $fullPath - id: $id - ) @client { - project { - id - ciVariables { - nodes { - ...BaseCiVariable - ... on CiProjectVariable { - environmentScope - masked - protected - raw - } - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/mutations/project_update_variable.mutation.graphql b/app/assets/javascripts/ci_variable_list/graphql/mutations/project_update_variable.mutation.graphql deleted file mode 100644 index fde92cef4cb..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/mutations/project_update_variable.mutation.graphql +++ /dev/null @@ -1,31 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" - -mutation updateProjectVariable( - $variable: CiVariable! - $endpoint: String! - $fullPath: ID! - $id: ID! -) { - ciVariableMutation: updateProjectVariable( - variable: $variable - endpoint: $endpoint - fullPath: $fullPath - id: $id - ) @client { - project { - id - ciVariables { - nodes { - ...BaseCiVariable - ... on CiProjectVariable { - environmentScope - masked - protected - raw - } - } - } - } - errors - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/queries/group_variables.query.graphql b/app/assets/javascripts/ci_variable_list/graphql/queries/group_variables.query.graphql deleted file mode 100644 index 900154cd24d..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/queries/group_variables.query.graphql +++ /dev/null @@ -1,23 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" -#import "~/graphql_shared/fragments/page_info.fragment.graphql" - -query getGroupVariables($after: String, $first: Int = 100, $fullPath: ID!) { - group(fullPath: $fullPath) { - id - ciVariables(after: $after, first: $first) { - limit - pageInfo { - ...PageInfo - } - nodes { - ...BaseCiVariable - ... on CiGroupVariable { - environmentScope - masked - protected - raw - } - } - } - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/queries/project_environments.query.graphql b/app/assets/javascripts/ci_variable_list/graphql/queries/project_environments.query.graphql deleted file mode 100644 index 921e0ca25b9..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/queries/project_environments.query.graphql +++ /dev/null @@ -1,11 +0,0 @@ -query getProjectEnvironments($fullPath: ID!) { - project(fullPath: $fullPath) { - id - environments { - nodes { - id - name - } - } - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/queries/project_variables.query.graphql b/app/assets/javascripts/ci_variable_list/graphql/queries/project_variables.query.graphql deleted file mode 100644 index ee75eba7547..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/queries/project_variables.query.graphql +++ /dev/null @@ -1,21 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" -#import "~/graphql_shared/fragments/page_info.fragment.graphql" - -query getProjectVariables($after: String, $first: Int = 100, $fullPath: ID!) { - project(fullPath: $fullPath) { - id - ciVariables(after: $after, first: $first) { - limit - pageInfo { - ...PageInfo - } - nodes { - ...BaseCiVariable - environmentScope - masked - protected - raw - } - } - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/queries/variables.query.graphql b/app/assets/javascripts/ci_variable_list/graphql/queries/variables.query.graphql deleted file mode 100644 index 9b255c3c182..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/queries/variables.query.graphql +++ /dev/null @@ -1,18 +0,0 @@ -#import "~/ci_variable_list/graphql/fragments/ci_variable.fragment.graphql" -#import "~/graphql_shared/fragments/page_info.fragment.graphql" - -query getVariables($after: String, $first: Int = 100) { - ciVariables(after: $after, first: $first) { - pageInfo { - ...PageInfo - } - nodes { - ...BaseCiVariable - ... on CiInstanceVariable { - masked - protected - raw - } - } - } -} diff --git a/app/assets/javascripts/ci_variable_list/graphql/settings.js b/app/assets/javascripts/ci_variable_list/graphql/settings.js deleted file mode 100644 index 02f6c226b0f..00000000000 --- a/app/assets/javascripts/ci_variable_list/graphql/settings.js +++ /dev/null @@ -1,242 +0,0 @@ -import axios from 'axios'; -import { - convertObjectPropsToCamelCase, - convertObjectPropsToSnakeCase, -} from '../../lib/utils/common_utils'; -import { convertToGraphQLId, getIdFromGraphQLId } from '../../graphql_shared/utils'; -import { - GRAPHQL_GROUP_TYPE, - GRAPHQL_PROJECT_TYPE, - groupString, - instanceString, - projectString, -} from '../constants'; -import getProjectVariables from './queries/project_variables.query.graphql'; -import getGroupVariables from './queries/group_variables.query.graphql'; -import getAdminVariables from './queries/variables.query.graphql'; - -const prepareVariableForApi = ({ variable, destroy = false }) => { - return { - ...convertObjectPropsToSnakeCase(variable), - id: getIdFromGraphQLId(variable?.id), - variable_type: variable.variableType.toLowerCase(), - secret_value: variable.value, - _destroy: destroy, - }; -}; - -const mapVariableTypes = (variables = [], kind) => { - return variables.map((ciVar) => { - return { - __typename: `Ci${kind}Variable`, - ...convertObjectPropsToCamelCase(ciVar), - id: convertToGraphQLId('Ci::Variable', ciVar.id), - variableType: ciVar.variable_type ? ciVar.variable_type.toUpperCase() : ciVar.variableType, - }; - }); -}; - -const prepareProjectGraphQLResponse = ({ data, id, errors = [] }) => { - return { - errors, - project: { - __typename: GRAPHQL_PROJECT_TYPE, - id: convertToGraphQLId(GRAPHQL_PROJECT_TYPE, id), - ciVariables: { - __typename: `Ci${GRAPHQL_PROJECT_TYPE}VariableConnection`, - pageInfo: { - __typename: 'PageInfo', - hasNextPage: false, - hasPreviousPage: false, - startCursor: '', - endCursor: '', - }, - nodes: mapVariableTypes(data.variables, projectString), - }, - }, - }; -}; - -const prepareGroupGraphQLResponse = ({ data, id, errors = [] }) => { - return { - errors, - group: { - __typename: GRAPHQL_GROUP_TYPE, - id: convertToGraphQLId(GRAPHQL_GROUP_TYPE, id), - ciVariables: { - __typename: `Ci${GRAPHQL_GROUP_TYPE}VariableConnection`, - pageInfo: { - __typename: 'PageInfo', - hasNextPage: false, - hasPreviousPage: false, - startCursor: '', - endCursor: '', - }, - nodes: mapVariableTypes(data.variables, groupString), - }, - }, - }; -}; - -const prepareAdminGraphQLResponse = ({ data, errors = [] }) => { - return { - errors, - ciVariables: { - __typename: `Ci${instanceString}VariableConnection`, - pageInfo: { - __typename: 'PageInfo', - hasNextPage: false, - hasPreviousPage: false, - startCursor: '', - endCursor: '', - }, - nodes: mapVariableTypes(data.variables, instanceString), - }, - }; -}; - -async function callProjectEndpoint({ endpoint, fullPath, variable, id, cache, destroy = false }) { - try { - const { data } = await axios.patch(endpoint, { - variables_attributes: [prepareVariableForApi({ variable, destroy })], - }); - - const graphqlData = prepareProjectGraphQLResponse({ data, id }); - - cache.writeQuery({ - query: getProjectVariables, - variables: { - fullPath, - after: null, - }, - data: graphqlData, - }); - return graphqlData; - } catch (e) { - return prepareProjectGraphQLResponse({ - data: cache.readQuery({ query: getProjectVariables, variables: { fullPath } }), - id, - errors: [...e.response.data], - }); - } -} - -const callGroupEndpoint = async ({ endpoint, fullPath, variable, id, cache, destroy = false }) => { - try { - const { data } = await axios.patch(endpoint, { - variables_attributes: [prepareVariableForApi({ variable, destroy })], - }); - - const graphqlData = prepareGroupGraphQLResponse({ data, id }); - - cache.writeQuery({ - query: getGroupVariables, - data: graphqlData, - }); - - return graphqlData; - } catch (e) { - return prepareGroupGraphQLResponse({ - data: cache.readQuery({ query: getGroupVariables, variables: { fullPath } }), - id, - errors: [...e.response.data], - }); - } -}; - -const callAdminEndpoint = async ({ endpoint, variable, cache, destroy = false }) => { - try { - const { data } = await axios.patch(endpoint, { - variables_attributes: [prepareVariableForApi({ variable, destroy })], - }); - - const graphqlData = prepareAdminGraphQLResponse({ data }); - - cache.writeQuery({ - query: getAdminVariables, - data: graphqlData, - }); - - return graphqlData; - } catch (e) { - return prepareAdminGraphQLResponse({ - data: cache.readQuery({ query: getAdminVariables }), - errors: [...e.response.data], - }); - } -}; - -export const resolvers = { - Mutation: { - addProjectVariable: async (_, { endpoint, fullPath, variable, id }, { cache }) => { - return callProjectEndpoint({ endpoint, fullPath, variable, id, cache }); - }, - updateProjectVariable: async (_, { endpoint, fullPath, variable, id }, { cache }) => { - return callProjectEndpoint({ endpoint, fullPath, variable, id, cache }); - }, - deleteProjectVariable: async (_, { endpoint, fullPath, variable, id }, { cache }) => { - return callProjectEndpoint({ endpoint, fullPath, variable, id, cache, destroy: true }); - }, - addGroupVariable: async (_, { endpoint, fullPath, variable, id }, { cache }) => { - return callGroupEndpoint({ endpoint, fullPath, variable, id, cache }); - }, - updateGroupVariable: async (_, { endpoint, fullPath, variable, id }, { cache }) => { - return callGroupEndpoint({ endpoint, fullPath, variable, id, cache }); - }, - deleteGroupVariable: async (_, { endpoint, fullPath, variable, id }, { cache }) => { - return callGroupEndpoint({ endpoint, fullPath, variable, id, cache, destroy: true }); - }, - addAdminVariable: async (_, { endpoint, variable }, { cache }) => { - return callAdminEndpoint({ endpoint, variable, cache }); - }, - updateAdminVariable: async (_, { endpoint, variable }, { cache }) => { - return callAdminEndpoint({ endpoint, variable, cache }); - }, - deleteAdminVariable: async (_, { endpoint, variable }, { cache }) => { - return callAdminEndpoint({ endpoint, variable, cache, destroy: true }); - }, - }, -}; - -export const mergeVariables = (existing, incoming, { args }) => { - if (!existing || !args?.after) { - return incoming; - } - - const { nodes, ...rest } = incoming; - const result = rest; - result.nodes = [...existing.nodes, ...nodes]; - - return result; -}; - -export const cacheConfig = { - cacheConfig: { - typePolicies: { - Query: { - fields: { - ciVariables: { - keyArgs: false, - merge: mergeVariables, - }, - }, - }, - Project: { - fields: { - ciVariables: { - keyArgs: ['fullPath', 'endpoint', 'id'], - merge: mergeVariables, - }, - }, - }, - Group: { - fields: { - ciVariables: { - keyArgs: ['fullPath'], - merge: mergeVariables, - }, - }, - }, - }, - }, -}; |