-
Notifications
You must be signed in to change notification settings - Fork 2
Make API consistent for creating instances #62
Comments
repositoryManager actually has a good reason to be there as the ChangeSet / Task structure relies on it heavily. It should not be optional/unsetable (as a decorator is) and therefore it should stay intact. Added support for both for a factory+decorators though. |
Hey. Just tried implementing this library today. Not sure if this is the best place to put this comment, but it relates to creating resources. When I create a resource using this part of the quick-start guide I see that the resulting URL that's called on the API server contains import Resource from '@hyral/core/lib/Resource/Resource';
const authenticateResource = repositoryManager.createRepository(connector, "authenticate");
const authenticate = Resource.create(null, "authenticate", {
email: "my@email.com",
password: "password",
}); This results in a GET request to Two things stand out as wrong here:
Am I doing something wrong? Thanks, |
Hi @ekampp , Awesome that you're using the library! I'm glad to help you out. Maybe a new issue with the label question whould be better as it would keep the current issues clean. I'm curious as to where a GET request would be triggered. It should not be triggered by the code above. I will try to reproduce it and if I'm able I will look into fixing it. If it actually does trigger a request it might have something to do with the lazy-loading decorator and an incorrect request to the data. To some up, it should certainly not result in a GET request to /authenticate/null. The code here is not wrong but it is incomplete if you want to create the resource on the server. For a change to be sent to the server you need to create a ChangeSet, persist the new resource and execute the changeset: ` // Use persistChange to only commit changes to the passed resource. // Send all queued changes to the backend. I hope this information helps! |
Repositories are now created via the repository manager. This should change to Repository.create and should use a default enabled decorator for the manager.
Same goes for HttpConnector, it should have a decorateable create factory method.
The text was updated successfully, but these errors were encountered: