rescript-relay 0.0.0-cli-61b2cdf6 → 0.0.0-next-af0f6500
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 +232 -0
- package/README.md +7 -11
- package/bsconfig.json +1 -1
- package/cli/cli.js +30 -35
- package/compiler.js +11 -0
- package/package.json +25 -25
- package/postinstall.js +66 -16
- package/ppx-linux +0 -0
- package/ppx-macos-latest +0 -0
- package/ppx-windows-latest +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/{ppx-darwin → relay-compiler-win-x64/relay.exe} +0 -0
- package/src/ReactDOMExperimental.bs.js +19 -1
- package/src/ReactDOMExperimental.res +16 -4
- package/src/ReactExperimental.bs.js +14 -16
- package/src/ReactExperimental.res +11 -22
- package/src/ReactExperimental.resi +18 -0
- package/src/RescriptRelay.bs.js +40 -28
- package/src/RescriptRelay.res +98 -39
- package/src/RescriptRelay.resi +78 -44
- package/src/RescriptRelay_Internal.bs.js +47 -13
- package/src/RescriptRelay_Internal.res +25 -18
- package/src/RescriptRelay_Internal.resi +1 -0
- package/src/experimental-router/RescriptRelayRouter.bs.js +16 -4
- package/src/experimental-router/RescriptRelayRouter.res +11 -2
- package/src/experimental-router/RescriptRelayRouter.resi +2 -0
- package/src/utils.js +207 -173
- package/src/utils.mjs +381 -0
- package/bin-darwin +0 -0
- package/bin-linux +0 -0
- package/compiler/compiler-cli.js +0 -54
- package/language-plugin/dist/index.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,237 @@
|
|
|
1
1
|
# master
|
|
2
2
|
|
|
3
|
+
# 1.0.0-rc.0
|
|
4
|
+
|
|
5
|
+
_[Here's a commit showing a project being upgraded to this version](https://github.com/zth/rescript-relay/commit/5831c2f1f0f13eedc1cb60468c32fd32b2dc01d3)_
|
|
6
|
+
|
|
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
|
+
|
|
9
|
+
## Upgrade versions
|
|
10
|
+
|
|
11
|
+
- `react-relay` and `relay-runtime` to `14.1.0`
|
|
12
|
+
- `react` and `react-dom` to `18.0.0`
|
|
13
|
+
|
|
14
|
+
## Remove Packages
|
|
15
|
+
|
|
16
|
+
You can go ahead and remove these packages, that are no longer needed, as the compiler is now shipped in the main package:
|
|
17
|
+
|
|
18
|
+
- `relay-config`
|
|
19
|
+
- `relay-compiler`
|
|
20
|
+
- `graphql` (if you don't use it for anything else)
|
|
21
|
+
|
|
22
|
+
## Improvements
|
|
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.
|
|
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.
|
|
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.
|
|
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!
|
|
47
|
+
|
|
48
|
+
## 1.0.0 development changelog
|
|
49
|
+
|
|
50
|
+
### rc.0
|
|
51
|
+
|
|
52
|
+
- _potentially breaking_ `getConnectionNodes` is now located directly in the generated module, and not in a nested `Utils` module.
|
|
53
|
+
- Support [provided variables](https://relay.dev/docs/api-reference/graphql-and-directives/#provided-variables). More info in the docs.
|
|
54
|
+
- Windows support! :tada:
|
|
55
|
+
- Fixed `setLinkedRecordToNull`, `setLinkedRecordToUndefined`, `setLinkedRecordsToNull` and `setLinkedRecordsToUndefined` methods by binding them to `setValue` instead of `setLinkedRecord/s`. Previously they were throwing an error because `setLinkedRecord/s` did not support "deleting" values using them. (@reck753)
|
|
56
|
+
- A `RelaySchemaAssets_graphql.res` is now emitted, containing type definitions for all enums and all input objects. This is designed to help with accessing and using enums and input objects outside of Relay's context. This means it'll be much easier to share makers for input objects, pass enums around, etc.
|
|
57
|
+
- Each fragment with a `@connection` now emits a `makeConnectionId` function that allows you to generate _type safe_ connection IDs. More on why this is useful in the documentation.
|
|
58
|
+
- _breaking_ Input object fields with illegal names in ReScript previously had their maker function argument names suffixed with `_`, like `~type_: string`. This is now instead _prefixed_, like `~_type: string`. Prefixing like this instead of suffixing means we can ship fully zero cost maker functions, which we couldn't before for input objects with illegal field names.
|
|
59
|
+
|
|
60
|
+
## beta.26
|
|
61
|
+
|
|
62
|
+
- Upgrade Relay packages to version `14.1.0`.
|
|
63
|
+
|
|
64
|
+
## beta.25
|
|
65
|
+
|
|
66
|
+
- Change signature of preload function (router related).
|
|
67
|
+
|
|
68
|
+
## beta.24
|
|
69
|
+
|
|
70
|
+
- Fix compatibility with ReScript v10
|
|
71
|
+
|
|
72
|
+
## beta.23
|
|
73
|
+
|
|
74
|
+
- Add Environment isServer option @MoOx
|
|
75
|
+
- Fix incorrect react-relay peerDependencies version @MoOx
|
|
76
|
+
- Remove rescript from dependencies @anmonteiro
|
|
77
|
+
- Fix instantiation of Relay context @vikfroberg
|
|
78
|
+
- Add undocumented holdGC method on relay store @MoOx
|
|
79
|
+
|
|
80
|
+
### beta.22
|
|
81
|
+
|
|
82
|
+
- Fix locations for `%relay.deferredComponent` so jump-to-definition, hover etc works as expected (pointing to the dynamically imported module rather than what the PPX produces).
|
|
83
|
+
- Add links for `Operation` module in `Query`, `Mutation`, `Subscription` and `Fragment` ([XiNiHa](https://github.com/XiNiHa))
|
|
84
|
+
|
|
85
|
+
### beta.21
|
|
86
|
+
|
|
87
|
+
- Support formatting commented out operations in the CLI ([reck753](https://github.com/reck753)).
|
|
88
|
+
- Support `@rescriptRelayIgnoreUnused` directive on fragment definitions to insert annotations that makes `reanalyze` consider all fields in the fragment used, even if they aren't.
|
|
89
|
+
- Support `@rescriptRelayAllowUnsafeEnum` directive on fields selecting enums, which will ignore safety measures for enums, meaning you won't need to add a catch all clause, etc. It'll essentially output the enum as an _input_ enum (as desribed in the docs).
|
|
90
|
+
|
|
91
|
+
### beta.20
|
|
92
|
+
|
|
93
|
+
- Fix enums appearing in `@raw_response_type` (local query updates, optimistic responses) to be input enums.
|
|
94
|
+
|
|
95
|
+
### beta.19
|
|
96
|
+
|
|
97
|
+
- Fix top level node interface issue.
|
|
98
|
+
|
|
99
|
+
### beta.18
|
|
100
|
+
|
|
101
|
+
- Fix `useTransition` bindings, where `startTransition` broke after going to React 18. Kudos to [Emilios1995](https://github.com/Emilios1995) for researching and finding the issue!
|
|
102
|
+
|
|
103
|
+
### beta.17
|
|
104
|
+
|
|
105
|
+
- Upgrade to stable React 18
|
|
106
|
+
|
|
107
|
+
### beta.16
|
|
108
|
+
|
|
109
|
+
- Fix bug that caused issues when using unions in optimistic responses and `commitLocalPayload`.
|
|
110
|
+
- 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.
|
|
111
|
+
|
|
112
|
+
### beta.15
|
|
113
|
+
|
|
114
|
+
- Fixes for input objects.
|
|
115
|
+
|
|
116
|
+
### beta.14
|
|
117
|
+
|
|
118
|
+
- Fixes a few issues introduced in `beta.13`.
|
|
119
|
+
- 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.
|
|
120
|
+
|
|
121
|
+
### beta.13
|
|
122
|
+
|
|
123
|
+
- `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).
|
|
124
|
+
- Make all object makers inlined. This should improve bundle size some.
|
|
125
|
+
- Support more Linux versions in CI (like the images Vercel uses).
|
|
126
|
+
|
|
127
|
+
### beta.12
|
|
128
|
+
|
|
129
|
+
- Make CLI work with `relay.config.cjs`.
|
|
130
|
+
|
|
131
|
+
### beta.11
|
|
132
|
+
|
|
133
|
+
- Another batch of experimental stuff... Nothing new in this version compared to `beta.9`.
|
|
134
|
+
|
|
135
|
+
### beta.10
|
|
136
|
+
|
|
137
|
+
- Sneaking out some experimental stuff... Nothing new in this version compared to `beta.9`.
|
|
138
|
+
|
|
139
|
+
### beta.9
|
|
140
|
+
|
|
141
|
+
- `recordSourceRecords` is now typed as `Js.Json.t` rather than being abstract.
|
|
142
|
+
- The field name of the `id` field of the `Node` interface is now configurable via `schemaConfig: {nodeInterfaceIdField: "idNameHere"}`.
|
|
143
|
+
|
|
144
|
+
### beta.8
|
|
145
|
+
|
|
146
|
+
- More fixes for conversion instructions in variables and input objects.
|
|
147
|
+
- Project now works in `"type": "module"` mode in `package.json` (kudos [cometkim](https://github.com/cometkim))
|
|
148
|
+
|
|
149
|
+
### beta.7
|
|
150
|
+
|
|
151
|
+
- Full support for `reanalyze` as all false positive dead code results from generated code are now suppressed.
|
|
152
|
+
- Bindings for `requiredFieldLogger` for logging when missing fields are encountered (kudos [Emilios1995](https://github.com/Emilios1995)).
|
|
153
|
+
- Fix bug with conversion instructions in variables with input instructions.
|
|
154
|
+
|
|
155
|
+
### beta.6
|
|
156
|
+
|
|
157
|
+
- Fix wrong enum type being printed in input objects
|
|
158
|
+
- 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
|
|
159
|
+
|
|
160
|
+
### beta.5
|
|
161
|
+
|
|
162
|
+
- 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.
|
|
163
|
+
- 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.
|
|
164
|
+
|
|
165
|
+
### beta.4
|
|
166
|
+
|
|
167
|
+
- Revert JSON.parse micro optimization experiment.
|
|
168
|
+
|
|
169
|
+
### beta.3
|
|
170
|
+
|
|
171
|
+
- Fix issue with duplicate keys being printed in the conversion instructions.
|
|
172
|
+
- Get rid of the need of nullability conversion instructions, and infer them instead.
|
|
173
|
+
|
|
174
|
+
### beta.2
|
|
175
|
+
|
|
176
|
+
- Fix issue with recursive input objects not being converted correctly.
|
|
177
|
+
|
|
178
|
+
# 0.23.0
|
|
179
|
+
|
|
180
|
+
_[Here's a commit showing a project being upgraded to this version](https://github.com/zth/rescript-relay/commit/6e96dfafaec918b1d4e9519d3fcbf5e5c46be6c0)_
|
|
181
|
+
|
|
182
|
+
Finally, a new release! This brings the Relay version to 12, and the React version to 18 (in rc.0 at the time of writing). This release has a few breaking changes which are necessary as we're slowly approaching version 1.0.0 of RescriptRelay. Check the new "Migrations" section below for a few scripts you can run to help the migration.
|
|
183
|
+
|
|
184
|
+
## Upgrade versions
|
|
185
|
+
|
|
186
|
+
- `react-relay` to `12.0.0`
|
|
187
|
+
- `relay-compiler` to `12.0.0`
|
|
188
|
+
- `relay-config` to `12.0.0`
|
|
189
|
+
- `relay-runtime` to `12.0.0`
|
|
190
|
+
|
|
191
|
+
React to React 18 rc:
|
|
192
|
+
|
|
193
|
+
- `react` to `rc` (`yarn add react@rc`)
|
|
194
|
+
- `react-dom` to `rc`(`yarn add react-dom@rc`)
|
|
195
|
+
|
|
196
|
+
## Migrations
|
|
197
|
+
|
|
198
|
+
Want help migrating most of the changes in this release? Install [comby](https://comby.dev) and run the migrations below (paste them into your terminal at the root of your project). Comby will guide you through the proposed changes.
|
|
199
|
+
|
|
200
|
+
- `comby 'ReactExperimental.unstable_useDeferredValue(:[1])' 'ReactExperimental.useDeferredValue(:[1])' .res -matcher .re -exclude-dir node_modules -review`
|
|
201
|
+
- `comby 'ReactExperimental.renderConcurrentRootAtElementWithId' 'ReactDOMExperimental.renderConcurrentRootAtElementWithId' .res -matcher .re -exclude-dir node_modules -review`
|
|
202
|
+
- `comby 'let (:[1], :[2]) = ReactExperimental.unstable_useTransition()' 'let (:[2], :[1]) = ReactExperimental.useTransition()' .res -matcher .re -exclude-dir node_modules -review`
|
|
203
|
+
|
|
204
|
+
## Breaking changes
|
|
205
|
+
|
|
206
|
+
- Remove `reason-promise` (unless you're using it for something else yourself and want to keep it). We're waiting for the official new Promise bindings, but since they seem to be quite far away, we'll have to revert back to stock `Js.Promise` for now. This is because `reason-promise` clashes with other Promise bindings that people might want to use before the new official ones are actually shipped.
|
|
207
|
+
- `ReactExperimental.unstable_useTransition` is now called `ReactExperimental.useTransition`, and the order of the tuple that's returned has been reversed to align with the underlying API. This means that what was before `let (startTransition, isTransitioning) = ReactExperimental.unstable_useTransition()` is now `let (isTransitioning, startTransition) = ReactExperimental.useTransition()` (migration available above).
|
|
208
|
+
- `ReactExperimental.unstable_useDeferredValue` is now called `ReactExperimental.useDeferredValue` (migration available above).
|
|
209
|
+
- `ReactExperimental.renderConcurrentRootAtElementWithId` has moved to `ReactDOMExperimental`: `ReactDOMExperimental.renderConcurrentRootAtElementWithId` (migration available above).
|
|
210
|
+
|
|
211
|
+
## Fixes & misc
|
|
212
|
+
|
|
213
|
+
- You're now allowed to configure Relay via `package.json`.
|
|
214
|
+
|
|
215
|
+
# 0.22.0
|
|
216
|
+
|
|
217
|
+
This release brings a few `rescript-relay-cli` improvements under the hood, as well as the breaking (but very easily fixable) change of uncurrying the `sink` methods received back from `RescriptRelay.Observable.make`.
|
|
218
|
+
|
|
219
|
+
## Breaking changes
|
|
220
|
+
|
|
221
|
+
- Uncurry `sink` methods. What was previously `sink => sink.error(err)` etc should now instead be `sink => sink.error(. err)`.
|
|
222
|
+
|
|
223
|
+
## Fixes & misc
|
|
224
|
+
|
|
225
|
+
- Improvements to the `remove-unused-fields` CLI.
|
|
226
|
+
|
|
227
|
+
# 0.21.1
|
|
228
|
+
|
|
229
|
+
- A few bug fixes to the `remove-unused-fields` command in the CLI.
|
|
230
|
+
|
|
231
|
+
# 0.21.0
|
|
232
|
+
|
|
233
|
+
- Adds `rescript-relay-cli`, a CLI for removing unused fields and formatting GraphQL in your project. Read more [here](https://github.com/zth/rescript-relay/blob/master/packages/rescript-relay-cli/README.md) (especially look at `remove-unused-fields`).
|
|
234
|
+
|
|
3
235
|
# 0.20.1
|
|
4
236
|
|
|
5
237
|
Quick patch release fixing the Linux binaries that broke with the last release.
|
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# rescript-relay
|
|
2
2
|
|
|
3
|
-
Use Relay with ReScript
|
|
3
|
+
Use Relay with ReScript.
|
|
4
4
|
|
|
5
5
|
[**Join our Discord**](https://discord.gg/wzj4EN8XDc)
|
|
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) => {
|