Skip to content

Commit ea2f9b7

Browse files
authored
Merge pull request #160 from illusionalsagacity/uncurry-internals-works-on-rescript-10
Uncurries internals for rescript 11 compatibility
2 parents fbf33cb + d1d4967 commit ea2f9b7

29 files changed

+299
-262
lines changed

EXAMPLES/bsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"name": "examples",
3+
"uncurried": false,
34
"graphql": {
45
"apolloMode": true,
6+
"uncurried": false,
57
"extendMutation": "ApolloClient.GraphQL_PPX.ExtendMutation",
68
"extendQuery": "ApolloClient.GraphQL_PPX.ExtendQuery",
79
"extendSubscription": "ApolloClient.GraphQL_PPX.ExtendSubscription",

EXAMPLES/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"start": "rescript build -with-deps -w"
1212
},
1313
"devDependencies": {
14-
"@reasonml-community/graphql-ppx": "1.2.4-1345e061.0",
14+
"@reasonml-community/graphql-ppx": "1.2.4-79d140a5.0",
1515
"graphql-client-example-server": "1.5.2",
1616
"html-webpack-plugin": "5.5.0",
17-
"rescript": "10.1.2",
17+
"rescript": "11.1.4",
1818
"webpack": "5.75.0",
1919
"webpack-cli": "5.0.1",
2020
"webpack-dev-server": "^4.11.1"
@@ -26,7 +26,7 @@
2626
"graphql": "^15.7.2",
2727
"react": "18.3.1",
2828
"react-dom": "18.3.1",
29-
"rescript-apollo-client": "3.2.0",
29+
"rescript-apollo-client": "*",
3030
"subscriptions-transport-ws": "0.11.0"
3131
}
3232
}

EXAMPLES/src/Apollo.res

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ let httpLink = ApolloClient.Link.HttpLink.make(
88
(),
99
)
1010

11+
let _retryLink = ApolloClient.Link.RetryLink.make(
12+
~attempts=RetryFunction(async (~count, ~operation as _, ~error as _) => count < 3),
13+
~delay=DelayFunction((~count as _, ~operation as _, ~error as _) => 1_000),
14+
(),
15+
)
16+
1117
let wsLink = {
1218
open ApolloClient.Link.WebSocketLink
1319
make(
@@ -42,3 +48,14 @@ let client = {
4248
(),
4349
)
4450
}
51+
52+
client.onClearStore(~cb=async () => {
53+
Js.log("store cleared")
54+
})
55+
56+
client.onResetStore(~cb=async () => {
57+
Js.log("store reset")
58+
})
59+
60+
let _ = client.clearStore()
61+
let _ = client.resetStore()

EXAMPLES/src/WebpackEntry.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@@warning("-3")
12
switch ReactDOM.querySelector("#root") {
23
| Some(el) =>
34
ReactDOM.render(

bsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "rescript-apollo-client",
3+
"uncurried": false,
34
"package-specs": [
45
{
56
"module": "commonjs",

src/@apollo/client/cache/core/ApolloClient__Cache_Core_Cache.res

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ module ApolloCache = {
181181
~fragmentName=?,
182182
(),
183183
) => {
184-
let safeParse = Utils.safeParse(Fragment.parse)
184+
let safeParse = Utils.safeParse(. Fragment.parse)
185185

186186
js
187187
->Js_.readFragment(
@@ -196,7 +196,7 @@ module ApolloCache = {
196196
(),
197197
)
198198
->Js.toOption
199-
->Belt.Option.map(safeParse)
199+
->Belt.Option.mapU(safeParse)
200200
}
201201

202202
let readQuery = (
@@ -212,7 +212,7 @@ module ApolloCache = {
212212
~canonizeResults=?,
213213
variables,
214214
) => {
215-
let safeParse = Utils.safeParse(Operation.parse)
215+
let safeParse = Utils.safeParse(. Operation.parse)
216216

217217
js
218218
->Js_.readQuery(
@@ -230,7 +230,7 @@ module ApolloCache = {
230230
~optimistic,
231231
)
232232
->Js.toOption
233-
->Belt.Option.map(safeParse)
233+
->Belt.Option.mapU(safeParse)
234234
}
235235

236236
let writeFragment = (
@@ -304,7 +304,7 @@ module ApolloCache = {
304304
~update,
305305
variables,
306306
) => {
307-
let safeParse = Utils.safeParse(Operation.parse)
307+
let safeParse = Utils.safeParse(. Operation.parse)
308308

309309
js
310310
->Js_.updateQuery(
@@ -330,7 +330,7 @@ module ApolloCache = {
330330
->Js.Nullable.fromOption,
331331
)
332332
->Js.toOption
333-
->Belt.Option.map(safeParse)
333+
->Belt.Option.mapU(safeParse)
334334
}
335335

336336
let updateFragment = (
@@ -345,7 +345,7 @@ module ApolloCache = {
345345
~update,
346346
(),
347347
) => {
348-
let safeParse = Utils.safeParse(Fragment.parse)
348+
let safeParse = Utils.safeParse(. Fragment.parse)
349349

350350
js
351351
->Js_.updateFragment(
@@ -367,7 +367,7 @@ module ApolloCache = {
367367
->Js.Nullable.fromOption,
368368
)
369369
->Js.toOption
370-
->Belt.Option.map(safeParse)
370+
->Belt.Option.mapU(safeParse)
371371
}
372372

373373
preserveJsPropsAndContext(

src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_InMemoryCache.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,5 +85,5 @@ let make: (
8585
?dataIdFromObject,
8686
?possibleTypes,
8787
?resultCaching,
88-
typePolicies: ?typePolicies->Belt.Option.map(TypePolicies.toJs),
88+
typePolicies: ?typePolicies->Belt.Option.mapU(TypePolicies.toJs),
8989
})->ApolloCache.fromJs

src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies.res

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ module TypePolicy = {
7878
fields?: t_fields,
7979
}
8080

81-
let toJs: t => Js_.t = t => {
82-
keyFields: ?t.keyFields->Belt.Option.map(KeyArgs.toJs),
81+
let toJs: (. t) => Js_.t = (. t) => {
82+
keyFields: ?t.keyFields->Belt.Option.mapU(KeyArgs.toJs),
8383
queryType: ?t.queryType,
8484
mutationType: ?t.mutationType,
8585
subscriptionType: ?t.subscriptionType,
86-
fields: ?t.fields->Belt.Option.map(fields =>
86+
fields: ?t.fields->Belt.Option.mapU((. fields) =>
8787
fields
88-
->Belt.Array.map(((fieldKey, t_field)) => (
88+
->Belt.Array.mapU((. (fieldKey, t_field)) => (
8989
fieldKey,
9090
switch t_field {
9191
| ConcatPagination(keyArgs) =>
@@ -97,7 +97,7 @@ module TypePolicy = {
9797

9898
| FieldPolicy(fieldPolicy) => fieldPolicy->FieldPolicy.toJs->Js_.FieldsUnion.fieldPolicy
9999
| FieldReadFunction(fieldReadFunction) =>
100-
fieldReadFunction->FieldReadFunction.toJs->Js_.FieldsUnion.fieldReadFunction
100+
FieldReadFunction.toJs(. fieldReadFunction)->Js_.FieldsUnion.fieldReadFunction
101101
},
102102
))
103103
->Js.Dict.fromArray
@@ -133,8 +133,8 @@ module TypePolicies = {
133133

134134
type t = array<(typename, TypePolicy.t)>
135135

136-
let toJs: t => Js_.t = t =>
137-
t->Belt.Array.map(((key, policy)) => (key, TypePolicy.toJs(policy)))->Js.Dict.fromArray
136+
let toJs: (. t) => Js_.t = (. t) =>
137+
t->Belt.Array.mapU((. (key, policy)) => (key, TypePolicy.toJs(. policy)))->Js.Dict.fromArray
138138
}
139139

140140
module PossibleTypesMap = {

src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies_FieldPolicy.res

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ module FieldMergeFunction = {
100100
// incoming: SafeReadonly<TIncoming>,
101101
// options: TOptions,
102102
// ) => SafeReadonly<TExisting>;
103-
type t<'existing> = ('existing, 'existing, FieldFunctionOptions.Js_.t) => 'existing
103+
type t<'existing> = (. 'existing, 'existing, FieldFunctionOptions.Js_.t) => 'existing
104104
}
105105

106-
let toJs: t<'existing> => Js_.t<'existing> = (t, existing, incoming, jsFieldFunctionOptions) =>
107-
t(existing, incoming, jsFieldFunctionOptions->FieldFunctionOptions.fromJs)
106+
let toJs: (. t<'existing>) => Js_.t<'existing> = (. t) =>
107+
(. existing, incoming, jsFieldFunctionOptions) =>
108+
t(existing, incoming, jsFieldFunctionOptions->FieldFunctionOptions.fromJs)
108109
}
109110

110111
module FieldMerge = {
@@ -116,22 +117,22 @@ module FieldMerge = {
116117
// FieldMergeFunction<TExisting, TIncoming, TOptions> | boolean;
117118
module FieldMergeUnion: {
118119
type t<'existing>
119-
let mergeFunction: FieldMergeFunction.Js_.t<'existing> => t<'existing>
120+
let mergeFunction: (. FieldMergeFunction.Js_.t<'existing>) => t<'existing>
120121
let true_: t<'existing>
121122
} = {
122123
@unboxed
123124
type rec t<'existing> = Any('a): t<'existing>
124-
let mergeFunction = (v: FieldMergeFunction.Js_.t<'existing>) => Any(v)
125+
let mergeFunction = (. v: FieldMergeFunction.Js_.t<'existing>) => Any(v)
125126
let true_ = Any(true)
126127
}
127128

128129
type t<'existing> = FieldMergeUnion.t<'existing>
129130
}
130131

131-
let toJs: t<'existing> => Js_.t<'existing> = x =>
132+
let toJs: (. t<'existing>) => Js_.t<'existing> = (. x) =>
132133
switch x {
133134
| MergeFunction(mergeFunction) =>
134-
mergeFunction->FieldMergeFunction.toJs->Js_.FieldMergeUnion.mergeFunction
135+
Js_.FieldMergeUnion.mergeFunction(. FieldMergeFunction.toJs(. mergeFunction))
135136
| True => Js_.FieldMergeUnion.true_
136137
}
137138
}
@@ -141,11 +142,12 @@ module FieldReadFunction = {
141142

142143
module Js_ = {
143144
// export declare type FieldReadFunction<TExisting = any, TReadResult = TExisting> = (existing: SafeReadonly<TExisting> | undefined, options: FieldFunctionOptions) => TReadResult | undefined;
144-
type t<'existing> = (option<'existing>, FieldFunctionOptions.Js_.t) => 'existing
145+
type t<'existing> = (. option<'existing>, FieldFunctionOptions.Js_.t) => 'existing
145146
}
146147

147-
let toJs: t<'existing> => Js_.t<'existing> = (t, existing, jsFieldFunctionOptions) =>
148-
t(existing, jsFieldFunctionOptions->FieldFunctionOptions.fromJs)
148+
let toJs: (. t<'existing>) => Js_.t<'existing> = (. t) =>
149+
(. existing, jsFieldFunctionOptions) =>
150+
t(existing, jsFieldFunctionOptions->FieldFunctionOptions.fromJs)
149151
}
150152

151153
module KeySpecifier = {
@@ -200,7 +202,7 @@ module FieldPolicy_KeyArgs = {
200202
type t = KeyArgsUnion.t
201203
}
202204

203-
let toJs: t => Js_.t = x =>
205+
let toJs: (. t) => Js_.t = (. x) =>
204206
switch x {
205207
| KeySpecifier(keySpecifier) => keySpecifier->Js_.KeyArgsUnion.keySpecifier
206208
| KeyArgsFunction(keyArgsFunction) => keyArgsFunction->Js_.KeyArgsUnion.keyArgsFunction
@@ -229,8 +231,8 @@ module FieldPolicy = {
229231
}
230232

231233
let toJs: t<'existing> => Js_.t<'existing> = t => {
232-
keyArgs: ?t.keyArgs->Belt.Option.map(FieldPolicy_KeyArgs.toJs),
233-
read: ?t.read->Belt.Option.map(FieldReadFunction.toJs),
234-
merge: ?t.merge->Belt.Option.map(FieldMerge.toJs),
234+
keyArgs: ?t.keyArgs->Belt.Option.mapU(FieldPolicy_KeyArgs.toJs),
235+
read: ?t.read->Belt.Option.mapU(FieldReadFunction.toJs),
236+
merge: ?t.merge->Belt.Option.mapU(FieldMerge.toJs),
235237
}
236238
}

0 commit comments

Comments
 (0)