Skip to content

Commit

Permalink
Expose child route path params (#149)
Browse files Browse the repository at this point in the history
* initial implementation

* changeset

* readme

* cleanup

* format
  • Loading branch information
zth authored Jan 31, 2024
1 parent 6405bd7 commit 94cf864
Show file tree
Hide file tree
Showing 28 changed files with 203 additions and 129 deletions.
5 changes: 5 additions & 0 deletions .changeset/fair-kids-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rescript-relay-router": minor
---

Expose any child route params to parent routes.
12 changes: 6 additions & 6 deletions examples/client-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"devDependencies": {
"@remix-run/web-fetch": "^4.1.3",
"@rescript/react": "0.12.0-alpha.2",
"@rescript/react": "^0.12.0",
"@vitejs/plugin-react-refresh": "1.3.6",
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
Expand All @@ -39,17 +39,17 @@
"npm-run-all": "^4.1.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-relay": "15.0.0",
"relay-runtime": "15.0.0",
"rescript": "11.0.0-beta.4",
"rescript-relay": "3.0.0-alpha.1",
"react-relay": "16.0.0",
"relay-runtime": "16.0.0",
"rescript": "11.0.1",
"rescript-relay": "3.0.0-rc.3",
"rollup": "^2",
"rollup-plugin-visualizer": "5.5.0",
"vite": "^4.4.9",
"vite-plugin-html": "3.2.0"
},
"dependencies": {
"@rescript/core": "^0.5.0",
"@rescript/core": "^0.6.0",
"history": "^5.2.0",
"jsonc-parser": "^3.0.0",
"rescript-relay-router": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let make = (~todo) => {
let (todo, refetch) = TodoFragment.useRefetchable(todo)
let (mutate, isMutating) = UpdateTodoItemMutation.use()
let (isRefetching, startTransition) = ReactExperimental.useTransition()
let completed = todo.completed->Option.getWithDefault(false)
let completed = todo.completed->Option.getOr(false)
let {setParams} = Routes.Root.Todos.Single.Route.useQueryParams()
let isShowingMore = todo.isShowingMore->Option.isSome

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let renderer = Routes.Root.Todos.Single.Route.makeRenderer(
~fetchPolicy=StoreOrNetwork,
~variables={
id: todoId,
showMore: showMore->Option.getWithDefault(false),
showMore: showMore->Option.getOr(false),
},
)
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"@remix-run/web-fetch": "^4.1.3",
"@rescript/react": "0.12.0-alpha.2",
"@rescript/react": "^0.12.0",
"@vitejs/plugin-react-refresh": "1.3.3",
"chalk": "^5.0.1",
"chokidar": "^3.5.3",
Expand All @@ -45,17 +45,17 @@
"npm-run-all": "^4.1.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-relay": "15.0.0",
"relay-runtime": "15.0.0",
"rescript": "11.0.0-beta.4",
"rescript-relay": "3.0.0-alpha.1",
"react-relay": "16.0.0",
"relay-runtime": "16.0.0",
"rescript": "11.0.1",
"rescript-relay": "3.0.0-rc.3",
"rollup": "^2",
"rollup-plugin-visualizer": "5.5.0",
"vite": "^4.4.9",
"vite-plugin-html": "3.2.0"
},
"dependencies": {
"@rescript/core": "^0.5.0",
"@rescript/core": "^0.6.0",
"history": "^5.2.0",
"jsonc-parser": "^3.0.0",
"node-fetch": "^3.2.0",
Expand Down
5 changes: 2 additions & 3 deletions examples/express/src/bindings/NodeJs.res
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
@scope("process.env") @val external nodeEnv: Nullable.t<string> = "NODE_ENV"
let isProduction = nodeEnv->Nullable.toOption->Option.getWithDefault("development") === "production"
let isProduction = nodeEnv->Nullable.toOption->Option.getOr("development") === "production"

@scope("process.env") @val external enableFileserver: Nullable.t<string> = "ENABLE_FILESERVER"
let shouldEnableFileserver =
enableFileserver->Nullable.toOption->Option.getWithDefault("false") === "true"
let shouldEnableFileserver = enableFileserver->Nullable.toOption->Option.getOr("false") === "true"

module Fs = {
module Stats = {
Expand Down
2 changes: 1 addition & 1 deletion examples/express/src/components/SingleTodoDisplay.res
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let make = (~todo) => {
let (todo, refetch) = TodoFragment.useRefetchable(todo)
let (mutate, isMutating) = UpdateTodoItemMutation.use()
let (isRefetching, startTransition) = ReactExperimental.useTransition()
let completed = todo.completed->Option.getWithDefault(false)
let completed = todo.completed->Option.getOr(false)
let {setParams} = Routes.Root.Todos.Single.Route.useQueryParams()
let isShowingMore = todo.isShowingMore->Option.isSome

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let renderer = Routes.Root.Todos.Single.Route.makeRenderer(
~fetchPolicy=StoreOrNetwork,
~variables={
id: todoId,
showMore: showMore->Option.getWithDefault(false),
showMore: showMore->Option.getOr(false),
},
)
},
Expand Down
16 changes: 8 additions & 8 deletions examples/express/src/routes/__generated__/RouteDeclarations.res

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion examples/express/src/routes/__generated__/Route__Root_route.res

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 94cf864

Please sign in to comment.