-
-
Notifications
You must be signed in to change notification settings - Fork 94
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
add create member to resource class #2838
Comments
Thanks for the report! Is this mainly about discoverability? I.e., you couldn't figure out how to write code to create - or is it also about readability - i.e., Resource.getList.push doesn't make sense. |
the latter mostly |
Hmm, curious about the use case: Do you want to create a new item and not add it to a list? Do you have a list endpoint at all? |
For context, the API was modeled after Backbone collections |
Hmm, push is the standard terminology I've found: Do you have a suggestion for a better way to distinguish adding to end, beginning, or inserted in sorted order? |
I am having a slightly different but related issue, which I can open a new issue for if necessary. I cannot determine how to extend const InternalUserBaseResource = createResource({
urlPrefix,
path: 'internal/users/:userId',
schema: InternalUser,
Endpoint: AuthdEndpoint
})
export const InternalUserResource = InternalUserBaseResource.extend({
...InternalUserBaseResource,
getList: {
...InternalUserBaseResource.getList,
push: {
...InternalUserBaseResource.getList.push,
body: {} as InternalUser & { password: string }
}
}
}) I get the following error:
I may have missed it but I don't see anywhere in the docs or migration guide how we're supposed to extend this new |
@jacobcossman Thanks for the report. A few things of note:
This means you can achieve what you desire by using the override version of Resource.extend export const InternalUserResource = createResource({
urlPrefix,
path: 'internal/users/:userId',
schema: InternalUser,
Endpoint: AuthdEndpoint
}).extend({
getList: {
body: {} as InternalUser & { password: string }
}
}); In an effort to help others avoid this confusion - was this the upgrade guide you were looking at? If not, could you link to what you were looking at? PS) To help others more easily find issues, I would prefer new issue opened and simply include a reference to related issues when mentioning. It can be difficult to navigate in a block of comments for things, but including links ensures people can still find slightly related things easily. |
@ntucker thanks so much! Yes, the upgrade guide you linked is what I was looking at. I think a note under the Resource.extend() section for this specific use case would be very helpful. Also noted about opening new issues 👍 |
Is your feature request related to a problem? Please describe.
at the moment the documented way to create a new item is to leverage getList.push per https://dataclient.io/rest/api/createResource#push which is pretty unintuitive, i'd love to see a create method replace that to more closely follow the get, update, delete methods
The text was updated successfully, but these errors were encountered: