I
I
Ilya2018-05-30 10:36:41
ORM
Ilya, 2018-05-30 10:36:41

Why can deserialization fail?

When deserializing data, for some reason a wild glitch begins leading to constant calls to the server, we use ORM on the client side, something similar to this , but written under JSONAPI .
The problem started when the relations of the Vehicle model were nested with the Contract model, below is the short code:
Code of the Vehicle model:

export default class Vehicle extends Model {

  static type() {
    return 'vehicle'
  }

  static relationships() {
    return {
      contract: this.hasOne(Contract, 'contract')
    }
  }

}

Contract model code:
export default class Contract extends Model {

  static type() {
    return 'contract'
  }

  static relationships() {
    return {
      vehicles: this.hasMany(Vehicle, 'vehicles', true)
    }
  }

}

There are suspicions that the deserializer does not like such mutual nesting, but I may be wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question