diff options
Diffstat (limited to 'app/assets/javascripts/graphql_shared')
-rw-r--r-- | app/assets/javascripts/graphql_shared/utils.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/assets/javascripts/graphql_shared/utils.js b/app/assets/javascripts/graphql_shared/utils.js new file mode 100644 index 00000000000..a262fbd9ac3 --- /dev/null +++ b/app/assets/javascripts/graphql_shared/utils.js @@ -0,0 +1,12 @@ +/** + * 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 default {}; |