Platform: @ngrx/data: how to configure the use of plural resource names for all http requests

Created on 23 Feb 2020  路  3Comments  路  Source: ngrx/platform

By convention, an HTTP request targeting a single entity item contains the lowercase, singular version of the entity type name. For example, if the entity type entityName is "Hero", the default data service will POST to a URL such as 'api/hero'.

Our rest api was designed to always use the plural name for the resource(s). How can I configure @ngrx/data to always use the plural resource name for any http requests? I feel like I'm probably missing the obvious.

I would be willing to submit a PR for the docs :heart:

[x ] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No

Data question

Most helpful comment

I recently got hit in the face with this one. This design decision is baffling to me. RESTful resources should all share the same convention...
GET products
GET products/1
PUT products/1
POST products
DELETE products/1

I've never seen any RESTful resource alter the pluralization within a single resource. Why did you guys decide to make people jump through hoops for following web standards?

All 3 comments

I think we go through this in our docs.
If this doesn't provide enough information, please feel free to re-open the issue.

Thanks for the example. I'm glad there's an example in the docs.

Two notes:

  1. There are a couple compilation issues with the example (pluralizer is misspelled as pluralizzer once, and the private pluralizer can't override the parent's private pluralizer). I just submitted https://github.com/ngrx/platform/pull/2490 to fix these.
  2. It would be nice if this were a simple config option, like the pluralNames property. Would it be possible to add that?

I recently got hit in the face with this one. This design decision is baffling to me. RESTful resources should all share the same convention...
GET products
GET products/1
PUT products/1
POST products
DELETE products/1

I've never seen any RESTful resource alter the pluralization within a single resource. Why did you guys decide to make people jump through hoops for following web standards?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandonroberts picture brandonroberts  路  3Comments

oxiumio picture oxiumio  路  3Comments

NathanWalker picture NathanWalker  路  3Comments

axmad22 picture axmad22  路  3Comments

smorandi picture smorandi  路  3Comments