src/client/components/referenceInputUtils/index.js
function _loadSingleObject(object, keyProperty, labelProperty, objectLoader) {
  if (hasIn(object, labelProperty)) {
    // label exists -> return object as it is
    return Promise.resolve(object);
  } else if (object[keyProperty] === undefined) {
    // key property is not specified -> return object as it is
    return Promise.resolve(object);
  } else {
    return objectLoader(object[keyProperty]).then((response) => {
      return _getObjectWithFallback(response.body, keyProperty, labelProperty)
    }).catch((error) => {
      return _getObjectWithFallback(object, keyProperty, labelProperty)
    })
  }
}
function _loadSingleObject(object, keyProperty, labelProperty, objectLoader) {
  if (hasIn(object, labelProperty)) {
    // label exists -> return object as it is
    return Promise.resolve(object);
  } else if (object[keyProperty] === undefined) {
    // key property is not specified -> return object as it is
    return Promise.resolve(object);
  } else {
    return objectLoader(object[keyProperty]).then((response) => {
      return _getObjectWithFallback(response.body, keyProperty, labelProperty)
    }).catch((error) => {
      return _getObjectWithFallback(object, keyProperty, labelProperty)
    })
  }
}
function _loadSingleObject ( object , keyProperty , labelProperty , objectLoader ) { if ( hasIn ( object , labelProperty ) ) { // label exists -> return object as it is return Promise . resolve ( object ) ; } else if ( object [ keyProperty ] === undefined ) { // key property is not specified -> return object as it is return Promise . resolve ( object ) ; } else { return objectLoader ( object [ keyProperty ] ) . then ( ( response ) => { return _getObjectWithFallback ( response . body , keyProperty , labelProperty ) } ) . catch ( ( error ) => { return _getObjectWithFallback ( object , keyProperty , labelProperty ) } ) } }
If object has [labelProperty] -> object
else load object from enpoint
if result has [labelProperty] -> return result
else return fallback

@param object
@param keyProperty
@param labelProperty
@param objectLoader
@returns {*}
@private
If object has [ labelProperty ] - > object else load object from enpoint if result has [ labelProperty ] - > return result else return fallback