archive/refactoring/definition/merge.js
function handleConflict(definition, method, name, type, tgt, src) {
  const _method = method ?
    method :
    defaultConflictResolution;
  // allow the method to be a function that returns the new name
  // and type configuration
  if (typeof _method === 'function') {
    return _method(definition, name, type, tgt, src);
  }

  switch (_method) {
    // merges the target and source configurations
    case NameConflictResolution.MERGE:
      return { name, config: merge(tgt, src) };

    // throws an error
    case NameConflictResolution.ERROR:
      throw new Error('Duplicate ' + type + ' name "' + name +
      '" is not allowed ' + 'when conflict is set to ' +
      NameConflictResolution.ERROR);

    // prints a warning and then overwrites the existing type definition
    case NameConflictResolution.WARN:
      definition.emit(FactoryEvent.WARN, 'GraphQLFactoryWarning: duplicate ' +
      'type name "' + name + '" found. Merging ' + type +
      ' configuration')
      return { name, config: merge(tgt, src) };

    // ignores the definition
    case NameConflictResolution.SKIP:
      return { name, config: tgt };

    // silently overwrites the value
    case NameConflictResolution.OVERWRITE:
      return { name, config: src };

    default:
      throw new Error('Invalid name conflict resolution');
  }
}
function handleConflict(definition, method, name, type, tgt, src) {
  const _method = method ?
    method :
    defaultConflictResolution;
  // allow the method to be a function that returns the new name
  // and type configuration
  if (typeof _method === 'function') {
    return _method(definition, name, type, tgt, src);
  }

  switch (_method) {
    // merges the target and source configurations
    case NameConflictResolution.MERGE:
      return { name, config: merge(tgt, src) };

    // throws an error
    case NameConflictResolution.ERROR:
      throw new Error('Duplicate ' + type + ' name "' + name +
      '" is not allowed ' + 'when conflict is set to ' +
      NameConflictResolution.ERROR);

    // prints a warning and then overwrites the existing type definition
    case NameConflictResolution.WARN:
      definition.emit(FactoryEvent.WARN, 'GraphQLFactoryWarning: duplicate ' +
      'type name "' + name + '" found. Merging ' + type +
      ' configuration')
      return { name, config: merge(tgt, src) };

    // ignores the definition
    case NameConflictResolution.SKIP:
      return { name, config: tgt };

    // silently overwrites the value
    case NameConflictResolution.OVERWRITE:
      return { name, config: src };

    default:
      throw new Error('Invalid name conflict resolution');
  }
}
function handleConflict ( definition , method , name , type , tgt , src ) { const _method = method ? method : defaultConflictResolution ; // allow the method to be a function that returns the new name // and type configuration if ( typeof _method === 'function' ) { return _method ( definition , name , type , tgt , src ) ; } switch ( _method ) { // merges the target and source configurations case NameConflictResolution . MERGE : return { name , config : merge ( tgt , src ) } ; // throws an error case NameConflictResolution . ERROR : throw new Error ( 'Duplicate ' + type + ' name "' + name + '" is not allowed ' + 'when conflict is set to ' + NameConflictResolution . ERROR ) ; // prints a warning and then overwrites the existing type definition case NameConflictResolution . WARN : definition . emit ( FactoryEvent . WARN , 'GraphQLFactoryWarning: duplicate ' + 'type name "' + name + '" found. Merging ' + type + ' configuration' ) return { name , config : merge ( tgt , src ) } ; // ignores the definition case NameConflictResolution . SKIP : return { name , config : tgt } ; // silently overwrites the value case NameConflictResolution . OVERWRITE : return { name , config : src } ; default : throw new Error ( 'Invalid name conflict resolution' ) ; } }
Handles a type name conflict
returns an object containing the type name to use
and the type configuration to use.
@param {*} method
@param {*} name
@param {*} prefix
Handles a type name conflict returns an object containing the type name to use and the type configuration to use .