Skip to content

Commit

Permalink
the rest?
Browse files Browse the repository at this point in the history
  • Loading branch information
illusionalsagacity committed Oct 7, 2024
1 parent cfbfb12 commit 3d0b221
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ yarn-error.log
.vscode/
lib/
node_modules/
.yarn/install-state.gz
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ module TypePolicy = {
// };
// };
type t = {
keyFields: option<KeyArgs.Js_.t>,
queryType: option<bool>,
mutationType: option<bool>,
subscriptionType: option<bool>,
fields: option<Js.Dict.t<FieldsUnion.t>>,
keyFields?: KeyArgs.Js_.t,
queryType?: bool,
mutationType?: bool,
subscriptionType?: bool,
fields?: Js.Dict.t<FieldsUnion.t>,
}
}

Expand All @@ -71,19 +71,19 @@ module TypePolicy = {
type t_fields = array<(fieldKey, t_field)>

type t = {
keyFields: option<KeyArgs.t>,
queryType: option<bool>,
mutationType: option<bool>,
subscriptionType: option<bool>,
fields: option<t_fields>,
keyFields?: KeyArgs.t,
queryType?: bool,
mutationType?: bool,
subscriptionType?: bool,
fields?: t_fields,
}

let toJs: (. t) => Js_.t = (. t) => {
keyFields: t.keyFields->Belt.Option.map(KeyArgs.toJs),
queryType: t.queryType,
mutationType: t.mutationType,
subscriptionType: t.subscriptionType,
fields: t.fields->Belt.Option.map(fields =>
keyFields: ?t.keyFields->Belt.Option.map(KeyArgs.toJs),
queryType: ?t.queryType,
mutationType: ?t.mutationType,
subscriptionType: ?t.subscriptionType,
fields: ?t.fields->Belt.Option.map(fields =>
fields
->Belt.Array.map(((fieldKey, t_field)) => (
fieldKey,
Expand All @@ -104,6 +104,7 @@ module TypePolicy = {
),
}

@deprecated("Construct the record directly instead")
let make: (
~fields: t_fields=?,
~keyFields: KeyArgs.t=?,
Expand All @@ -112,11 +113,11 @@ module TypePolicy = {
~subscriptionType: bool=?,
unit,
) => t = (~fields=?, ~keyFields=?, ~mutationType=?, ~queryType=?, ~subscriptionType=?, ()) => {
fields,
keyFields,
mutationType,
queryType,
subscriptionType,
?fields,
?keyFields,
?mutationType,
?queryType,
?subscriptionType,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ module FieldPolicy_KeyArgs = {

module FieldPolicy = {
type t<'existing> = {
keyArgs: option<FieldPolicy_KeyArgs.t>,
read: option<FieldReadFunction.t<'existing>>,
merge: option<FieldMerge.t<'existing>>,
keyArgs?: FieldPolicy_KeyArgs.t,
read?: FieldReadFunction.t<'existing>,
merge?: FieldMerge.t<'existing>,
}

module Js_ = {
Expand All @@ -222,15 +222,15 @@ module FieldPolicy = {
// merge?: FieldMergeFunction<TExisting, TIncoming> | boolean;
// };
type t<'existing> = {
keyArgs: option<FieldPolicy_KeyArgs.Js_.t>,
read: option<FieldReadFunction.Js_.t<'existing>>,
merge: option<FieldMerge.Js_.t<'existing>>,
keyArgs?: FieldPolicy_KeyArgs.Js_.t,
read?: FieldReadFunction.Js_.t<'existing>,
merge?: FieldMerge.Js_.t<'existing>,
}
}

let toJs: t<'existing> => Js_.t<'existing> = t => {
keyArgs: t.keyArgs->Belt.Option.map(FieldPolicy_KeyArgs.toJs),
read: t.read->Belt.Option.map(FieldReadFunction.toJs),
merge: t.merge->Belt.Option.map(FieldMerge.toJs),
keyArgs: ?t.keyArgs->Belt.Option.map(FieldPolicy_KeyArgs.toJs),
read: ?t.read->Belt.Option.map(FieldReadFunction.toJs),
merge: ?t.merge->Belt.Option.map(FieldMerge.toJs),
}
}
22 changes: 11 additions & 11 deletions src/@apollo/client/core/ApolloClient__Core_ApolloClient.res
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,15 @@ let make: (
jsClient,
~options=MutationOptions.toJs(
{
awaitRefetchQueries,
context,
errorPolicy,
fetchPolicy,
?awaitRefetchQueries,
?context,
?errorPolicy,
?fetchPolicy,
mutation: Operation.query,
optimisticResponse,
updateQueries,
refetchQueries,
update,
?optimisticResponse,
?updateQueries,
?refetchQueries,
?update,
variables,
},
~mapJsVariables,
Expand Down Expand Up @@ -858,11 +858,11 @@ let make: (
jsClient,
~options=SubscriptionOptions.toJs(
{
fetchPolicy,
?fetchPolicy,
query: Operation.query,
variables,
errorPolicy,
context,
?errorPolicy,
?context,
},
~mapJsVariables,
~serializeVariables=Operation.serializeVariables,
Expand Down
85 changes: 42 additions & 43 deletions src/@apollo/client/core/ApolloClient__Core_WatchQueryOptions.res
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,19 @@ module SubscribeToMoreOptions = {
document: Graphql.documentNode,
// We don't allow optional variables because it's not typesafe
variables: 'subscriptionVariables,
updateQuery: option<
updateQuery?:
UpdateQueryFn.Js_.t<'jsQueryData, 'subscriptionVariables, 'jsSubscriptionData>,
>,
onError: option<Js.Exn.t => unit>,
context: option<Js.Json.t>,
onError?: Js.Exn.t => unit,
context?: Js.Json.t,
}
}

type t<'queryData, 'subscriptionVariables, 'subscriptionData> = {
document: Graphql.documentNode,
variables: 'subscriptionVariables,
updateQuery: option<UpdateQueryFn.t<'queryData, 'subscriptionVariables, 'subscriptionData>>,
onError: option<Js.Exn.t => unit>,
context: option<Js.Json.t>,
updateQuery?: UpdateQueryFn.t<'queryData, 'subscriptionVariables, 'subscriptionData>,
onError?: Js.Exn.t => unit,
context?: Js.Json.t,
}

let toJs: (
Expand All @@ -262,16 +261,16 @@ module SubscribeToMoreOptions = {
) => {
document: t.document,
variables: t.variables,
updateQuery: t.updateQuery->Belt.Option.map(
updateQuery: ?t.updateQuery->Belt.Option.map(
UpdateQueryFn.toJs(
~onParseError=onUpdateQueryParseError,
~querySafeParse,
~querySerialize,
~subscriptionSafeParse,
),
),
onError: t.onError,
context: t.context,
onError: ?t.onError,
context: ?t.context,
}
}

Expand All @@ -288,18 +287,18 @@ module SubscriptionOptions = {
query: Graphql.documentNode,
// We don't allow optional variables because it's not typesafe
variables: 'jsVariables,
fetchPolicy: option<FetchPolicy.Js_.t>,
errorPolicy: option<ErrorPolicy.Js_.t>,
context: option<Js.Json.t>,
fetchPolicy?: FetchPolicy.Js_.t,
errorPolicy?: ErrorPolicy.Js_.t,
context?: Js.Json.t,
}
}

type t<'variables> = {
query: Graphql.documentNode,
variables: 'variables,
fetchPolicy: option<FetchPolicy.t>,
errorPolicy: option<ErrorPolicy.t>,
context: option<Js.Json.t>,
fetchPolicy?: FetchPolicy.t,
errorPolicy?: ErrorPolicy.t,
context?: Js.Json.t,
}

let toJs: (
Expand All @@ -309,9 +308,9 @@ module SubscriptionOptions = {
) => Js_.t<'jsVariables> = (t, ~mapJsVariables, ~serializeVariables) => {
query: t.query,
variables: t.variables->serializeVariables->mapJsVariables,
fetchPolicy: t.fetchPolicy->Belt.Option.map(FetchPolicy.toJs),
errorPolicy: t.errorPolicy->Belt.Option.map(ErrorPolicy.toJs),
context: t.context,
fetchPolicy: ?t.fetchPolicy->Belt.Option.map(FetchPolicy.toJs),
errorPolicy: ?t.errorPolicy->Belt.Option.map(ErrorPolicy.toJs),
context: ?t.context,
}
}

Expand Down Expand Up @@ -371,31 +370,31 @@ module MutationOptions = {
// }
type t<'jsData, 'jsVariables> = {
mutation: Graphql.documentNode,
context: option<Js.Json.t>,
fetchPolicy: option<FetchPolicy__noCacheExtracted.Js_.t>,
context?: Js.Json.t,
fetchPolicy?: FetchPolicy__noCacheExtracted.Js_.t,
// ...extends MutationBaseOption,
awaitRefetchQueries: option<bool>,
errorPolicy: option<ErrorPolicy.Js_.t>,
optimisticResponse: option<(. 'jsVariables) => 'jsData>,
update: option<MutationUpdaterFn.Js_.t<'jsData>>,
updateQueries: option<MutationQueryReducersMap.Js_.t<'jsData>>,
refetchQueries: option<RefetchQueryDescription.Js_.t>,
awaitRefetchQueries?: bool,
errorPolicy?: ErrorPolicy.Js_.t,
optimisticResponse?: (. 'jsVariables) => 'jsData,
update?: MutationUpdaterFn.Js_.t<'jsData>,
updateQueries?: MutationQueryReducersMap.Js_.t<'jsData>,
refetchQueries?: RefetchQueryDescription.Js_.t,
// We don't allow optional variables because it's not typesafe
variables: 'jsVariables,
}
}

type t<'data, 'variables, 'jsVariables> = {
context: option<Js.Json.t>,
fetchPolicy: option<FetchPolicy__noCacheExtracted.t>,
context?: Js.Json.t,
fetchPolicy?: FetchPolicy__noCacheExtracted.t,
mutation: Graphql.documentNode,
// ...extends MutationBaseOptions,
awaitRefetchQueries: option<bool>,
errorPolicy: option<ErrorPolicy.t>,
optimisticResponse: option<'jsVariables => 'data>,
refetchQueries: option<RefetchQueryDescription.t>,
update: option<MutationUpdaterFn.t<'data>>,
updateQueries: option<MutationQueryReducersMap.t<'data>>,
awaitRefetchQueries?: bool,
errorPolicy?: ErrorPolicy.t,
optimisticResponse?: 'jsVariables => 'data,
refetchQueries?: RefetchQueryDescription.t,
update?: MutationUpdaterFn.t<'data>,
updateQueries?: MutationQueryReducersMap.t<'data>,
variables: 'variables,
}

Expand All @@ -412,17 +411,17 @@ module MutationOptions = {
~serialize,
~serializeVariables,
) => {
awaitRefetchQueries: t.awaitRefetchQueries,
context: t.context,
errorPolicy: t.errorPolicy->Belt.Option.map(ErrorPolicy.toJs),
fetchPolicy: t.fetchPolicy->Belt.Option.map(FetchPolicy__noCacheExtracted.toJs),
awaitRefetchQueries: ?t.awaitRefetchQueries,
context: ?t.context,
errorPolicy: ?t.errorPolicy->Belt.Option.map(ErrorPolicy.toJs),
fetchPolicy: ?t.fetchPolicy->Belt.Option.map(FetchPolicy__noCacheExtracted.toJs),
mutation: t.mutation,
optimisticResponse: t.optimisticResponse->Belt.Option.map(optimisticResponse =>
optimisticResponse: ?t.optimisticResponse->Belt.Option.map(optimisticResponse =>
(. variables) => optimisticResponse(variables)->serialize
),
refetchQueries: t.refetchQueries->Belt.Option.map(RefetchQueryDescription.toJs),
update: t.update->Belt.Option.map(MutationUpdaterFn.toJs(~safeParse)),
updateQueries: t.updateQueries->Belt.Option.map(MutationQueryReducersMap.toJs(~safeParse)),
refetchQueries: ?t.refetchQueries->Belt.Option.map(RefetchQueryDescription.toJs),
update: ?t.update->Belt.Option.map(MutationUpdaterFn.toJs(~safeParse)),
updateQueries: ?t.updateQueries->Belt.Option.map(MutationQueryReducersMap.toJs(~safeParse)),
variables: t.variables->serializeVariables->mapJsVariables,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,29 @@ module Options = {
// }
// }
type t = {
delay: option<T_delayUnion.t>,
attempts: option<T_attemptsUnion.t>,
delay?: T_delayUnion.t,
attempts?: T_attemptsUnion.t,
}
}

type t_delay = DelayFunctionOptions(DelayFunctionOptions.t) | DelayFunction(DelayFunction.t)
type t_attempts = RetryFunctionOptions(RetryFunctionOptions.t) | RetryFunction(RetryFunction.t)

type t = {
delay: option<t_delay>,
attempts: option<t_attempts>,
delay?: t_delay,
attempts?: t_attempts,
}

let toJs: t => Js_.t = t => {
delay: t.delay->Belt.Option.map(delay =>
delay: ?t.delay->Belt.Option.map(delay =>
switch delay {
| DelayFunctionOptions(delayFunctionOptions) =>
Js_.T_delayUnion.delayFunctionOptions(delayFunctionOptions)
| DelayFunction(delayFunction) =>
Js_.T_delayUnion.delayFunction(delayFunction->DelayFunction.toJs)
}
),
attempts: t.attempts->Belt.Option.map(attempts =>
attempts: ?t.attempts->Belt.Option.map(attempts =>
switch attempts {
| RetryFunctionOptions(retryFunctionOptions) =>
Js_.T_attemptsUnion.retryFunctionOptions(retryFunctionOptions->RetryFunctionOptions.toJs)
Expand All @@ -82,7 +82,7 @@ module Js_ = {
let make = (~attempts=?, ~delay=?, ()) =>
Js_.make(
Options.toJs({
attempts: attempts,
delay: delay,
attempts: ?attempts,
delay: ?delay,
}),
)
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ let useSubscription:
Operation.query,
SubscriptionHookOptions.toJs(
{
client: client,
fetchPolicy: fetchPolicy,
onSubscriptionData: onSubscriptionData,
onSubscriptionComplete: onSubscriptionComplete,
subscription: None,
shouldResubscribe: shouldResubscribe,
skip: skip,
client: ?client,
fetchPolicy: ?fetchPolicy,
onSubscriptionData: ?onSubscriptionData,
onSubscriptionComplete: ?onSubscriptionComplete,
shouldResubscribe: ?shouldResubscribe,
skip: ?skip,
variables: variables,
},
~mapJsVariables,
Expand Down
Loading

0 comments on commit 3d0b221

Please sign in to comment.