From 26d29f8d0fa73f470f70f459aade5a6f7668ccfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Tsnobiladz=C3=A9?= Date: Wed, 13 Sep 2023 16:51:47 +0200 Subject: [PATCH] fix loadFn not a function (#141) * fix loadFn not a function * update changeset --- .changeset/famous-fishes-raise.md | 5 +++++ .../src/routes/__generated__/RouteDeclarations.res | 8 ++++---- .../src/routes/__generated__/RouteDeclarations.res | 8 ++++---- .../cli/RescriptRelayRouterCli__Codegen.res | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .changeset/famous-fishes-raise.md diff --git a/.changeset/famous-fishes-raise.md b/.changeset/famous-fishes-raise.md new file mode 100644 index 0000000..c13be88 --- /dev/null +++ b/.changeset/famous-fishes-raise.md @@ -0,0 +1,5 @@ +--- +"rescript-relay-router": patch +--- + +Fix the type of the generated loadFn in loadRouteRenderer diff --git a/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res b/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res index 75094af..5ad1d7d 100644 --- a/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res +++ b/examples/client-rendering/src/routes/__generated__/RouteDeclarations.res @@ -13,7 +13,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, @@ -82,7 +82,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root__Todos_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, @@ -150,7 +150,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root__Todos__ByStatus_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__ByStatus_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, @@ -220,7 +220,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root__Todos__Single_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__Single_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, diff --git a/examples/express/src/routes/__generated__/RouteDeclarations.res b/examples/express/src/routes/__generated__/RouteDeclarations.res index 75094af..5ad1d7d 100644 --- a/examples/express/src/routes/__generated__/RouteDeclarations.res +++ b/examples/express/src/routes/__generated__/RouteDeclarations.res @@ -13,7 +13,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, @@ -82,7 +82,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root__Todos_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, @@ -150,7 +150,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root__Todos__ByStatus_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__ByStatus_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, @@ -220,7 +220,7 @@ let make = (~prepareDisposeTimeout=5 * 60 * 1000): array Js.import(Root__Todos__Single_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(Root__Todos__Single_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = (. ~environment: RescriptRelay.Environment.t, ~pathParams: Js.Dict.t, diff --git a/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res b/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res index 3eb2243..f6ec28e 100644 --- a/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res +++ b/packages/rescript-relay-router/cli/RescriptRelayRouterCli__Codegen.res @@ -520,7 +520,7 @@ let rec getRouteDefinition = (route: printableRoute, ~indentation): string => { let str = `{ let routeName = "${routeName}" - let loadRouteRenderer = () => Js.import(${routeName}_route_renderer.renderer)->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) + let loadRouteRenderer = () => (() => Js.import(${routeName}_route_renderer.renderer))->Obj.magic->doLoadRouteRenderer(~routeName, ~loadedRouteRenderers) let makePrepareProps = ${route->getMakePrepareProps(~returnMode=ForInlinedRouteFn)} {