zth / rescript-relay

Use Relay with ReScript.
https://rescript-relay-documentation.vercel.app/docs/getting-started
339 stars 53 forks source link

Experimental router polyvariant path params do not match #408

Closed mattbeedle closed 1 year ago

mattbeedle commented 1 year ago

Not sure if this is already a known issue since the experimental router is still not public, but I'm having problems with the polyvariant matching.

The following code generates the correct variants, but does not match any of the /recipes/... variant paths. It will always render the Recipe renderer.

{
  "path": "recipes",
  "name": "FilteredRecipes",
  "children": [
    {
      "path": ":course(all|breakfast|lunch|dinner|appetizer|sides|dip|smoothie)",
      "name": "ByCourse"
    },
},
{
  "path": "recipes/:id",
  "name": "Recipe"
},

However, if I define every route individually it will match fine:

{
  "path": "recipes",
  "name": "FilteredRecipes",
  "children": [
    {
      "path": "all",
      "name": "All"
    },
    {
      "path": "breakfast",
      "name": "Breakfast"
     }
  }
  .......
},
{
  "path": "recipes/:id",
  "name": "Recipe"
},

I have another layer of nesting inside the each of the recipes routes and that layer is also dynamic, so manually defining every one will be quite a lot of typing :)

zth commented 1 year ago

Interesting! This should definitely work, thanks for reporting.

Are you actively using the router, or just trying things out?

mattbeedle commented 1 year ago

I just refactored a current production project to use it. This is the last thing I need to get working in order to release.

zth commented 1 year ago

@mattbeedle let's get it sorted then! 😃 I'll invite you to the repo too since it's not public yet

mattbeedle commented 1 year ago

Awesome, thx! I created an issue for it there along with a small sample app.

zth commented 1 year ago

This has been fixed in the router.