<commit_before>import {
  Document,
  FragmentDefinition,
} from 'graphql';

import flatten = require('lodash.flatten');

import {
  getFragmentDefinitions,
} from './queries/getFromAST';

// A map going from the name of a fragment to that fragment's definition.
// The point is to keep track of fragments that exist and print a warning if we encounter two
// fragments that have the same name, i.e. the values *should* be of arrays of length 1.
// Note: this variable is exported solely for unit testing purposes. It should not be touched
// directly by application code.
export let fragmentDefinitionsMap: { [fragmentName: string]: FragmentDefinition[] } = {};

// Specifies whether or not we should print warnings about conflicting fragment names.
let printFragmentWarnings = true;

// Takes a document, extracts the FragmentDefinitions from it and puts
// them in this.fragmentDefinitions. The second argument specifies the fragments
// that the fragment in the document depends on. The fragment definition array from the document
// is concatenated with the fragment definition array passed as the second argument and this
// concatenated array is returned.
let haveWarned = false;

export function createFragment(
  doc: Document,
  fragments: (FragmentDefinition[] | FragmentDefinition[][]) = [],
  internalUse = false,
): FragmentDefinition[] {

  if (!internalUse) {
    if (! haveWarned) {
      if (process.env.NODE_ENV !== 'production') {
        console.warn(
            '"createFragment" is deprecated and will be removed in the upcoming versions, ' +
            'please refer to the documentation for how to define fragments: ' +
            'http://dev.apollodata.com/react/fragments.html.'
        );
      }
      /* istanbul ignore if */
      if (process.env.NODE_ENV !== 'test') {
        // When running tests, we want to print the warning every time<commit_msg>change deprecation message<commit_after>import {
  Document,
  FragmentDefinition,
} from 'graphql';

import flatten = require('lodash.flatten');

import {
  getFragmentDefinitions,
} from './queries/getFromAST';

// A map going from the name of a fragment to that fragment's definition.
// The point is to keep track of fragments that exist and print a warning if we encounter two
// fragments that have the same name, i.e. the values *should* be of arrays of length 1.
// Note: this variable is exported solely for unit testing purposes. It should not be touched
// directly by application code.
export let fragmentDefinitionsMap: { [fragmentName: string]: FragmentDefinition[] } = {};

// Specifies whether or not we should print warnings about conflicting fragment names.
let printFragmentWarnings = true;

// Takes a document, extracts the FragmentDefinitions from it and puts
// them in this.fragmentDefinitions. The second argument specifies the fragments
// that the fragment in the document depends on. The fragment definition array from the document
// is concatenated with the fragment definition array passed as the second argument and this
// concatenated array is returned.
let haveWarned = false;

export function createFragment(
  doc: Document,
  fragments: (FragmentDefinition[] | FragmentDefinition[][]) = [],
  internalUse = false,
): FragmentDefinition[] {

  if (!internalUse) {
    if (! haveWarned) {
      if (process.env.NODE_ENV !== 'production') {
        console.warn(
            '"createFragment" is deprecated and will be removed in version 0.6, ' +
            'please refer to the documentation for how to define fragments: ' +
            'http://dev.apollodata.com/react/fragments.html.'
        );
      }
      /* istanbul ignore if */
      if (process.env.NODE_ENV !== 'test') {
        // When running tests, we want to print the warning every time
{'fraction_non_alphanumeric': 0.08874172185430464, 'fraction_numerical': 0.0010596026490066225, 'mean_word_length': 3.500595947556615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6134963', 'n_tokens_mistral': 967, 'n_tokens_neox': 930, 'n_words': 424}