Welcome to mirror list, hosted at ThFree Co, Russian Federation.

graphql_helpers.js « __helpers__ « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 63123aa046fac2af08dee724d9b37b42d941e243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
 * Returns a clone of the given object with all __typename keys omitted,
 * including deeply nested ones.
 *
 * Only works with JSON-serializable objects.
 *
 * @param {object} An object with __typename keys (e.g., a GraphQL response)
 * @returns {object} A new object with no __typename keys
 */
export const stripTypenames = (object) => {
  return JSON.parse(
    JSON.stringify(object, (key, value) => (key === '__typename' ? undefined : value)),
  );
};