Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error if .find has payload type and EntityFactory mismatch #90

Open
MichaelHirn opened this issue Aug 7, 2019 · 0 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@MichaelHirn
Copy link
Contributor

Example:

Assume CID 0x123 responds to payload { type: 'DataProperty', ...}.

The proposed behavior for .find('0x123') is:

client.Entity.find('0x123'); // does not throw, returns `entity instanceof Rlay_Entity`
client.DataProperty.find('0x123'); // does not throw, returns `entity instanceof Rlay_DataProperty`
client.Individual.find('0x123'); // does throw; error message: expected payload to be of type 'Individual' but got 'DataProperty'. Call client.DataProperty.find.
client.{X != DataProperty || Entity}.find('0x123'); // does throw; same as client.Individual.find

The point of this is, that you can assert a specific Entity type when using find.

If you want to fetch it without knowing the type of the entity one should call client.Entity.find

@MichaelHirn MichaelHirn added the enhancement New feature or request label Aug 7, 2019
@MichaelHirn MichaelHirn self-assigned this Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant