holidayextras / jsonapi-client

Easily consume a json:api service in Javascript.
MIT License
68 stars 19 forks source link

Reference to the same relationship from two different fields? #64

Open fsauter opened 7 years ago

fsauter commented 7 years ago

Hi guys,

following scenario: I have an item with two tax code fields - different names but same type (and maybe same record):

Item
    belongs_to :tax_code_sales, class_name: TaxCode
    belongs_to :tax_code_purchase, class_name: TaxCode

If I have an item that has for both fields the same tax code (same ID) and I call toJSONTree the tax_code_purchase field contains "[Circular]".

Is there a way to create a condition to allow a scenario like this?

I guess it's related to this line: Resource.js#L238 but before I dig into it.. do you have any ideas/hints/solutions?

Cheers Florian