<commit_before>import gql from 'graphql-tag';

export const Fragments = {};
export const FragmentsExtensions = {}; // will be used on startup

/*

Get a fragment's name from its text

*/
export const extractFragmentName = fragmentText => fragmentText.match(/fragment (.*) on/)[1];

/*

Get a query resolver's name from its text

*/
export const extractResolverName = resolverText => resolverText.trim().substr(0, resolverText.trim().indexOf('{'));


/*<commit_msg>create a helper to get the default fragment name<commit_after>import gql from 'graphql-tag';

export const Fragments = {};
export const FragmentsExtensions = {}; // will be used on startup

/**
 * @param {*} collectionOrName A collection name, or a whole collection
 */
export const getDefaultFragmentName = (collectionOrName) => {
  const collectionName = typeof collectionOrName === 'string' ? collectionOrName : collectionOrName.options.collectionName;
  return `${collectionName}DefaultFragment`;
};

/*

Get a fragment's name from its text

*/
export const extractFragmentName = fragmentText => fragmentText.match(/fragment (.*) on/)[1];

/*

Get a query resolver's name from its text

*/
export const extractResolverName = resolverText => resolverText.trim().substr(0, resolverText.trim().indexOf('{'));


/*
{'fraction_non_alphanumeric': 0.12832550860719874, 'fraction_numerical': 0.003129890453834116, 'mean_word_length': 4.921296296296297, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6950563', 'n_tokens_mistral': 361, 'n_tokens_neox': 353, 'n_words': 114}