Collection camelCase relationship does not work (and collection names should not change casing in REST API) #994
Replies: 2 comments 2 replies
-
Hey @lksfrn — this is a good catch. We are actually working on enforcing snake-case for best-practice REST API reasons specifically. URL paths should always be snake-case. We are going to improve our config validation so that it is impossible to write a camel-case collection slug, which will improve the DX here a bit. What do you think? I'm going to convert this to a Feature Request discussion, but I'd love to keep the conversation going there! |
Beta Was this translation helpful? Give feedback.
-
I like to use a camelCase too, in my case i want to map older collections it will be very helpfull to deactivate snake-case and use camelCase instead, another feature will be allow singular collection names. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
When using collection with two or more words in camelCase, eg.
myExamples
, one cannot build a relationship field.Expected Behavior
It should work
myExamples
, one cannot build a relationship field.Current Behavior
The server crashed right after start.
Possible Solution
Do not change collecation name casing when accessing via REST.
Currently, said
myExamples
would be transformed tomy-examples
in REST API. I think this is bad from a numerous reasons:/api/my-examples
. But when your query your field, the casing remains in camelCase. Also when accessing globals, it is not transformed:/api/globals/myOtherGlobal
.Steps to Reproduce
https://github.com/lksfrn/payload-relationship-repro
Detailed Description
Payload version: 1.0.27
Beta Was this translation helpful? Give feedback.
All reactions