<NME> deserializer.js
<BEF> 'use strict'

var _ = require('lodash')

function defaultBeforeDeserialize (options, cb) {
  cb(null, options)
}

function defaultDeserialize (options, cb) {
  options.result = options.data.data.attributes || {}
  cb(null, options)
}

function defaultAfterDeserialize (options, cb) {
        var fkSuffix = null;
        var fk = null;
        if (_.isArray(clientRelation.data)) {
          relationType = _.result(_.find(clientRelation.data, 'type'), 'type');
          relationValue = _.map(clientRelation.data, function (val) {
            return val.id;
          });
          fkSuffix = 'Ids';
        } else {
          relationType = clientRelation.data.type;
          relationValue = clientRelation.data.id;
          fkSuffix = 'Id';
  var deserialize = typeof model.jsonApiDeserialize === 'function'
    ? model.jsonApiDeserialize
    : defaultDeserialize

  var afterDeserialize = typeof model.afterJsonApiDeserialize === 'function'
    ? model.afterJsonApiDeserialize
    : defaultAfterDeserialize

  var deserializeOptions = _.cloneDeep(options)

  beforeDeserialize(deserializeOptions, function (err, deserializeOptions) {
    if (err) return cb(err)
    deserialize(deserializeOptions, function (err, deserializeOptions) {
      if (err) return cb(err)
      afterDeserialize(deserializeOptions, function (err, deserializeOptions) {
        if (err) return cb(err)

        belongsToRelationships(deserializeOptions)
        return cb(null, deserializeOptions)
      })
    })
  })
}

function belongsToRelationships (options) {
  var data = options.data
  var model = options.model

  if (!data || !data.data || !model || !data.data.relationships) {
    return
  }

  _.each(data.data.relationships, function (relationship, name) {
    var serverRelation = model.relations[name]
    if (!serverRelation) return
    var type = serverRelation.type

    // only handle belongsTo
    if (type !== 'belongsTo') return

    var fkName = serverRelation.keyFrom
    var modelTo = serverRelation.modelFrom

    if (!modelTo) return false

    if (!relationship.data) {
      options.result[fkName] = null
    } else {
      options.result[fkName] = relationship.data.id
    }
  })
}

<MSG> Fix error if relation empty

<DFF> @@ -15,12 +15,18 @@ module.exports = function Deserializer (data, serverRelations) {
         var fkSuffix = null;
         var fk = null;
         if (_.isArray(clientRelation.data)) {
+          if (_.isEmpty(clientRelation.data)) {
+            return;
+          }
           relationType = _.result(_.find(clientRelation.data, 'type'), 'type');
           relationValue = _.map(clientRelation.data, function (val) {
             return val.id;
           });
           fkSuffix = 'Ids';
         } else {
+          if (clientRelation.data === null) {
+            return;
+          }
           relationType = clientRelation.data.type;
           relationValue = clientRelation.data.id;
           fkSuffix = 'Id';

Fix error if relation empty