Skip to content

Commit

Permalink
fix issue with PPX not actually converting all functions to uncurried
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Feb 26, 2024
1 parent d7e0d32 commit 4f125ab
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Set explicit peer dependencies: `@rescript/react >= 0.12.1`, `react-relay@16.0.0`, `relay-runtime@16.0.0`.
- Clean up connection handler generators now that v3 let us use a better representation.
- Fix issue with default args in connection id makers. https://github.com/zth/rescript-relay/pull/488
- Fix issue with PPX not actually converting all functions to uncurried.

# 3.0.0-rc.4

Expand Down
5 changes: 5 additions & 0 deletions packages/rescript-relay/__tests__/TestCompileInterfaces.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module SubFragment = %relay(`
fragment TestCompileInterfacesFragment_user on User {
lastName
}
`)
11 changes: 11 additions & 0 deletions packages/rescript-relay/__tests__/TestCompileInterfaces.resi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module SubFragment: {
module Types = TestCompileInterfacesFragment_user_graphql.Types
module Operation = TestCompileInterfacesFragment_user_graphql
let convertFragment: TestCompileInterfacesFragment_user_graphql.Types.fragment => TestCompileInterfacesFragment_user_graphql.Types.fragment
let use: RescriptRelay.fragmentRefs<
[> #TestCompileInterfacesFragment_user],
> => TestCompileInterfacesFragment_user_graphql.Types.fragment
let useOpt: option<RescriptRelay.fragmentRefs<[> #TestCompileInterfacesFragment_user]>> => option<
TestCompileInterfacesFragment_user_graphql.Types.fragment,
>
}

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

2 changes: 1 addition & 1 deletion packages/rescript-relay/rescript-relay-ppx/.ocamlformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
profile = default
version = 0.22.4
version = 0.26.1

field-space = tight-decl
break-cases = toplevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,25 @@ let uncurriedMapper =
:: expr.pexp_attributes;
}
| _ -> default_mapper.expr mapper expr);
structure =
(fun mapper structure ->
let handle_str_item item =
match item.pstr_desc with
| Pstr_value
(a1, [({pvb_expr = {pexp_desc = Pexp_fun _} as fn} as outerV)]) ->
{
(default_mapper.structure_item mapper item) with
pstr_desc =
Pstr_value
( a1,
[
{
outerV with
(* TODO: Should we care about actually figuring out the arity? *)
pvb_expr = uncurriedFun ~loc:outerV.pvb_loc ~arity:1 fn;
};
] );
}
| _ -> default_mapper.structure_item mapper item
in
List.map handle_str_item structure);
structure_item =
(fun mapper item ->
match item.pstr_desc with
| Pstr_value
(a1, [({pvb_expr = {pexp_desc = Pexp_fun _} as fn} as outerV)]) ->
{
(default_mapper.structure_item mapper item) with
pstr_desc =
Pstr_value
( a1,
[
{
outerV with
(* TODO: Should we care about actually figuring out the arity? *)
pvb_expr = uncurriedFun ~loc:outerV.pvb_loc ~arity:1 fn;
};
] );
}
| _ -> default_mapper.structure_item mapper item);
}

let mapStructureItem str =
Expand Down

0 comments on commit 4f125ab

Please sign in to comment.