summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/graphql_shared/utils.js
blob: 5487aeb9391808a08011255ccfc9cf44bd73ddf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
 * Ids generated by GraphQL endpoints are usually in the format
 * gid://gitlab/Environments/123. This method extracts Id number
 * from the Id path
 *
 * @param {String} gid GraphQL global ID
 * @returns {Number}
 */
export const getIdFromGraphQLId = (gid = '') =>
  parseInt(`${gid}`.replace(/gid:\/\/gitlab\/.*\//g, ''), 10) || null;

export const MutationOperationMode = {
  Append: 'APPEND',
  Remove: 'REMOVE',
  Replace: 'REPLACE',
};