rescript-relay 1.0.0-beta.2 → 1.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -6
- package/README.md +6 -10
- package/cli/cli.js +29 -35
- package/package.json +18 -9
- package/postinstall.js +7 -0
- package/ppx-darwin +0 -0
- package/ppx-linux +0 -0
- package/relay-compiler-linux-musl/relay +0 -0
- package/relay-compiler-linux-x64/relay +0 -0
- package/relay-compiler-macos-arm64/relay +0 -0
- package/relay-compiler-macos-x64/relay +0 -0
- package/src/ReactDOMExperimental.bs.js +3 -3
- package/src/ReactDOMExperimental.res +2 -3
- package/src/ReactExperimental.bs.js +14 -1
- package/src/ReactExperimental.res +9 -4
- package/src/ReactExperimental.resi +18 -0
- package/src/RescriptRelay.bs.js +13 -1
- package/src/RescriptRelay.res +48 -7
- package/src/RescriptRelay.resi +45 -8
- package/src/RescriptRelay_Internal.bs.js +42 -13
- package/src/RescriptRelay_Internal.res +22 -18
- package/src/RescriptRelay_Internal.resi +1 -0
- package/src/experimental-router/RescriptRelayRouter.bs.js +2 -1
- package/src/utils.js +184 -163
- package/src/utils.mjs +381 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
-
# 1.0.0-beta.
|
|
3
|
+
# 1.0.0-beta.20
|
|
4
4
|
|
|
5
5
|
_[Here's a commit showing a project being upgraded to this version](https://github.com/zth/rescript-relay/commit/5831c2f1f0f13eedc1cb60468c32fd32b2dc01d3)_
|
|
6
6
|
|
|
7
7
|
The time has finally come - RescriptRelay `1.0.0` is in beta! The one, big major thing this release brings is that the ReScript type generation for the Relay compiler has been completely rewritten, and fully integrated into the new Relay Rust compiler. The RescriptRelay fork of the compiler is available and maintained [here])(https://github.com/zth/relay/tree/rescript-relay).
|
|
8
8
|
|
|
9
|
+
## Upgrade versions
|
|
10
|
+
|
|
11
|
+
- `react-relay` and `relay-runtime` to `13.2.0`
|
|
12
|
+
- `react` and `react-dom` to `18.0.0`
|
|
13
|
+
|
|
9
14
|
## Remove Packages
|
|
10
15
|
|
|
11
16
|
You can go ahead and remove these packages, that are no longer needed, as the compiler is now shipped in the main package:
|
|
@@ -14,19 +19,119 @@ You can go ahead and remove these packages, that are no longer needed, as the co
|
|
|
14
19
|
- `relay-compiler`
|
|
15
20
|
- `graphql` (if you don't use it for anything else)
|
|
16
21
|
|
|
17
|
-
## Breaking Changes
|
|
18
|
-
|
|
19
|
-
- The compiler expects the `__generated__` folder to always exist, so if you're not committing your artifacts to source control, make sure you add a `.gitkeep` to the generated folder so git keeps it around.
|
|
20
|
-
|
|
21
22
|
## Improvements
|
|
22
23
|
|
|
23
24
|
- The compiler itself should be _much_ faster than the old one. An order of magnitude faster. Especially for incremental compilation in watch mode.
|
|
24
25
|
- There's no longer any need to manually select `__typename` on interfaces and unions for RescriptRelay's sake, unless you actually want to use it yourself.
|
|
25
|
-
- We now support the `@required` directive from Relay, which is a new directive that lets you force non-nullability for nullable fields on the client side. You can then choose to throw an error if null values are encountered, or let the null value bubble up. Docs are coming soon
|
|
26
|
+
- We now support the `@required` directive from Relay, which is a new directive that lets you force non-nullability for nullable fields on the client side. You can then choose to throw an error if null values are encountered, or let the null value bubble up. Docs are coming soon.
|
|
26
27
|
- The errors reported by the compiler is now quite a lot better.
|
|
28
|
+
- Full support for `reanalyze` as all false positive dead code results from generated code are now suppressed.
|
|
29
|
+
- Bindings for `requiredFieldLogger` for logging when missing fields are encountered (kudos [Emilios1995](https://github.com/Emilios1995)).
|
|
30
|
+
- Improved utils for [dealing with enums](https://rescript-relay-documentation.vercel.app/docs/enums).
|
|
31
|
+
- `recordSourceRecords` is now typed as `Js.Json.t` rather than being abstract.
|
|
32
|
+
|
|
33
|
+
## Breaking changes
|
|
34
|
+
|
|
35
|
+
- The list of disallowed field names has been adapted to ReScript (it was never properly updated for ReScript when moving from ReasonML). This means that _some of your variable prop names might be renamed_. One example - if you previously had a variable in GraphQL called `$to`, you'd interact with that as `to_` in ReScript. This is because RescriptRelay would pin `to` as a reserved word, and rename it for you. But, `to` _isn't_ actually a keyword in ReScript (it was in ReasonML), so with this release, that `to_` in ReScript will be renamed to `to`. The fix is to just update all `to_` to `to` - let the compiler guide you!
|
|
36
|
+
- Using variable names that are reserved words in ReScript is now _disallowed at the Relay compiler level_. This means that Relay won't compile your project if you have variables whose names are reserved words. The fix is to simply rename the variables.
|
|
37
|
+
- `refetchVariables` now works as intended with regards to supplying only the variables you want _changed_ when refetching, as [detailed under `variables` here](https://relay.dev/docs/next/api-reference/use-refetchable-fragment/#return-value). This means that what was previously `makeRefetchVariables(~someValue=123, ())` should now be `makeRefetchVariables(~someValue=Some(123), ())`.
|
|
38
|
+
Crash course:
|
|
39
|
+
|
|
40
|
+
- `makeRefetchVariables(~someValue=Some(123), ())` means _refetch, use the same values for all variables that was used in the last fetch, but change `someValue` to `123`_.
|
|
41
|
+
- `makeRefetchVariables(~someValue=None, ())` means _refetch, use the same values for all variables that was used in the last fetch, but change `someValue` to `null` (unsetting it)_.
|
|
42
|
+
- `makeRefetchVariables()` means _refetch, use the same values for all variables that was used in the last fetch, change nothing_.
|
|
43
|
+
|
|
44
|
+
This way you can surgically change only certain values when refetching, without having to keep track of the current values for the other values.
|
|
45
|
+
|
|
46
|
+
More details on this [in the docs](https://rescript-relay-documentation.vercel.app/docs/refetching-and-loading-more-data#makerefetchvariables). Thanks to [@tsnobip](https://github.com/tsnobip) for fixing this!
|
|
27
47
|
|
|
28
48
|
## Beta fix changelog
|
|
29
49
|
|
|
50
|
+
### unreleased
|
|
51
|
+
|
|
52
|
+
### beta.20
|
|
53
|
+
|
|
54
|
+
- Fix enums appearing in `@raw_response_type` (local query updates, optimistic responses) to be input enums.
|
|
55
|
+
|
|
56
|
+
### beta.19
|
|
57
|
+
|
|
58
|
+
- Fix top level node interface issue.
|
|
59
|
+
|
|
60
|
+
### beta.18
|
|
61
|
+
|
|
62
|
+
- Fix `useTransition` bindings, where `startTransition` broke after going to React 18. Kudos to [Emilios1995](https://github.com/Emilios1995) for researching and finding the issue!
|
|
63
|
+
|
|
64
|
+
### beta.17
|
|
65
|
+
|
|
66
|
+
- Upgrade to stable React 18
|
|
67
|
+
|
|
68
|
+
### beta.16
|
|
69
|
+
|
|
70
|
+
- Fix bug that caused issues when using unions in optimistic responses and `commitLocalPayload`.
|
|
71
|
+
- Add support for experimental [Relay Resolvers](https://relay.dev/docs/next/guides/relay-resolvers). Undocumented so far, but looking at the [test](https://github.com/zth/rescript-relay/blob/master/packages/rescript-relay/__tests__/Test_relayResolvers.res) and [definition file](https://github.com/zth/rescript-relay/blob/master/packages/rescript-relay/__tests__/TestRelayUserResolver.res) should give you a hint of how it works.
|
|
72
|
+
|
|
73
|
+
### beta.15
|
|
74
|
+
|
|
75
|
+
- Fixes for input objects.
|
|
76
|
+
|
|
77
|
+
### beta.14
|
|
78
|
+
|
|
79
|
+
- Fixes a few issues introduced in `beta.13`.
|
|
80
|
+
- The list of disallowed field names has been adapted to ReScript. This means that _some of your variable prop names might be renamed_. Check out the Breaking Changes section above for details.
|
|
81
|
+
|
|
82
|
+
### beta.13
|
|
83
|
+
|
|
84
|
+
- `refetchVariables` now works as intended with regards to supplying only the variables you want _changed_ when refetching, as [detailed under `variables` here](https://relay.dev/docs/next/api-reference/use-refetchable-fragment/#return-value). Check out the [docs](https://rescript-relay-documentation.vercel.app/docs/refetching-and-loading-more-data#makerefetchvariables).
|
|
85
|
+
- Make all object makers inlined. This should improve bundle size some.
|
|
86
|
+
- Support more Linux versions in CI (like the images Vercel uses).
|
|
87
|
+
|
|
88
|
+
### beta.12
|
|
89
|
+
|
|
90
|
+
- Make CLI work with `relay.config.cjs`.
|
|
91
|
+
|
|
92
|
+
### beta.11
|
|
93
|
+
|
|
94
|
+
- Another batch of experimental stuff... Nothing new in this version compared to `beta.9`.
|
|
95
|
+
|
|
96
|
+
### beta.10
|
|
97
|
+
|
|
98
|
+
- Sneaking out some experimental stuff... Nothing new in this version compared to `beta.9`.
|
|
99
|
+
|
|
100
|
+
### beta.9
|
|
101
|
+
|
|
102
|
+
- `recordSourceRecords` is now typed as `Js.Json.t` rather than being abstract.
|
|
103
|
+
- The field name of the `id` field of the `Node` interface is now configurable via `schemaConfig: {nodeInterfaceIdField: "idNameHere"}`.
|
|
104
|
+
|
|
105
|
+
### beta.8
|
|
106
|
+
|
|
107
|
+
- More fixes for conversion instructions in variables and input objects.
|
|
108
|
+
- Project now works in `"type": "module"` mode in `package.json` (kudos [cometkim](https://github.com/cometkim))
|
|
109
|
+
|
|
110
|
+
### beta.7
|
|
111
|
+
|
|
112
|
+
- Full support for `reanalyze` as all false positive dead code results from generated code are now suppressed.
|
|
113
|
+
- Bindings for `requiredFieldLogger` for logging when missing fields are encountered (kudos [Emilios1995](https://github.com/Emilios1995)).
|
|
114
|
+
- Fix bug with conversion instructions in variables with input instructions.
|
|
115
|
+
|
|
116
|
+
### beta.6
|
|
117
|
+
|
|
118
|
+
- Fix wrong enum type being printed in input objects
|
|
119
|
+
- Fix `__typename` not being automatically selected (and by that forcing a manual select) in some cases, even though it's not supposed to be required to select manually anymore
|
|
120
|
+
|
|
121
|
+
### beta.5
|
|
122
|
+
|
|
123
|
+
- Generate helpers for moving between unsafe enums coming from the server, and safe enums. Also, provide a "fromString" function for each enum used, that can be used to turn any string into your enum.
|
|
124
|
+
- Suppress dead code warnings _in most places_ when running `reanalyze` on a `rescript-relay` code base. Still a few things left to fix, that requires changes to reanalyze. But this should be much better than before.
|
|
125
|
+
|
|
126
|
+
### beta.4
|
|
127
|
+
|
|
128
|
+
- Revert JSON.parse micro optimization experiment.
|
|
129
|
+
|
|
130
|
+
### beta.3
|
|
131
|
+
|
|
132
|
+
- Fix issue with duplicate keys being printed in the conversion instructions.
|
|
133
|
+
- Get rid of the need of nullability conversion instructions, and infer them instead.
|
|
134
|
+
|
|
30
135
|
### beta.2
|
|
31
136
|
|
|
32
137
|
- Fix issue with recursive input objects not being converted correctly.
|
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@ Use Relay with ReScript.
|
|
|
6
6
|
|
|
7
7
|
## Getting started
|
|
8
8
|
|
|
9
|
-
> Are you using version `>= 0.13.0` and ReScript syntax with VSCode? Make sure you install our [
|
|
9
|
+
> Are you using version `>= 0.13.0` and ReScript syntax with VSCode? Make sure you install our [dedicated VSCode extension](https://marketplace.visualstudio.com/items?itemName=GabrielNordeborn.vscode-rescript-relay). Note: It only works with ReScript syntax.
|
|
10
10
|
|
|
11
11
|
Check out the [documentation](https://rescript-relay-documentation.vercel.app).
|
|
12
12
|
|
|
13
|
-
Also, check out the [changelog](CHANGELOG.md) - things will continue change
|
|
13
|
+
Also, check out the [changelog](CHANGELOG.md) - things will continue to change between versions (including breaking changes, although we'll try and keep them to a minimum) as we iterate and reach a stable version.
|
|
14
14
|
|
|
15
15
|
## What it looks like
|
|
16
16
|
|
|
@@ -18,15 +18,13 @@ Your components define what data they need through `%relay()`.
|
|
|
18
18
|
|
|
19
19
|
```rescript
|
|
20
20
|
/* Avatar.res */
|
|
21
|
-
module UserFragment = %relay(
|
|
22
|
-
`
|
|
21
|
+
module UserFragment = %relay(`
|
|
23
22
|
fragment Avatar_user on User {
|
|
24
23
|
firstName
|
|
25
24
|
lastName
|
|
26
25
|
avatarUrl
|
|
27
26
|
}
|
|
28
|
-
`
|
|
29
|
-
)
|
|
27
|
+
`)
|
|
30
28
|
|
|
31
29
|
@react.component
|
|
32
30
|
let make = (~user) => {
|
|
@@ -52,16 +50,14 @@ Hooks to use your fragments are autogenerated for you. The hook needs a _fragmen
|
|
|
52
50
|
|
|
53
51
|
```rescript
|
|
54
52
|
/* UserProfile.res */
|
|
55
|
-
module UserFragment = %relay(
|
|
56
|
-
`
|
|
53
|
+
module UserFragment = %relay(`
|
|
57
54
|
fragment UserProfile_user on User {
|
|
58
55
|
firstName
|
|
59
56
|
lastName
|
|
60
57
|
friendCount
|
|
61
58
|
...Avatar_user
|
|
62
59
|
}
|
|
63
|
-
`
|
|
64
|
-
)
|
|
60
|
+
`)
|
|
65
61
|
|
|
66
62
|
@react.component
|
|
67
63
|
let make = (~user) => {
|