Rebolon / json-reviver

Pattern to restore json object/string into real Entities. Even nested entities can be restored as expected.
2 stars 1 forks source link

Should we manage entity with only ID (in an object or a number) ? #1

Open Rebolon opened 6 years ago

Rebolon commented 6 years ago

When we call an Api, sometimes, it won't return full sub-entity but just the IRIs (this is what does ApiPlatform because it prevents huge data download, or paginations problem in sub-entities). So when we restore entity, should we allow the developper to ask for an automatic Api call ?

With this mode, we shall return a Promise (or an Observable) that will do all required Api call to retreive entities and transform them into real Entity.

Rebolon commented 6 years ago

I think that the first thing to do would be to allow the reviver to revive only EZprops. There might be at least 2 modes:

and we might add a way to auto download nested entities, maybe in a third mode.

Rebolon commented 6 years ago

for instance when we try to revive entities with nested entities represented by IRIS, then the Reviver will crash. So the first thing would be to fix this by checking json error from initFromJSON: in that case we should check the data and if it looks like an IRIS we should just log an info and return the string as is.