Closed zth closed 2 months ago
this is a very common need I have, thanks a lot for tackling it!
I'm just wondering about usability, I often have this issue with common types, couldn't we instead define a default value explicitly?
{ "name": "Members", "path": "members?search=string&first=(int:0)&after=string" }
This syntax is obviously just an example.
It's a trade off definitely of where to put this. With this approach, it's easy to keep default values for param types in sync over multiple routes without having to keep them updated manually. We also avoid cramming a bunch of ReScript code into the JSON route definition string (query param definitions are already pretty crowded). So that's the reason why I opted to do it like this.
Another nice to have feature to generate nicer links would be to get rid of the default values in the URL (might be related to #170 too): for example
Routes.Member.Route.makeLink(~first=0, ~search="Paul") == "members?search=Paul"
What do you think?
Yeah this would definitely be nice, and thinking a bit about I can't see why this shouldn't be the default case - don't set anything in the URL unless you explicitly pass it when creating the link. That's probably an easy adjustment in the PR.
this is a very common need I have, thanks a lot for tackling it!
I'm just wondering about usability, I often have this issue with common types, couldn't we instead define a default value explicitly?
This syntax is obviously just an example.
Another nice to have feature to generate nicer links would be to get rid of the default values in the URL (might be related to #170 too): for example
What do you think?