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 d9274dd
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 102 deletions.
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,
}),
)
6 changes: 3 additions & 3 deletions src/@apollo/client/react/types/ApolloClient__React_Types.res
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,11 @@ module QueryResult = {
{
document: Operation.query,
variables,
updateQuery,
onError: onError->Belt.Option.map((onError, error) =>
?updateQuery,
onError: ?onError->Belt.Option.map((onError, error) =>
onError(SubscriptionError(error))
),
context,
?context,
},
~onUpdateQueryParseError=parseError =>
switch onError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,36 @@ module ClientOptions = {
// inactivityTimeout?: number;
// }
type t = {
connectionParams: option<ConnectionParamsOptions.Js_.t>,
timeout: option<int>,
reconnect: option<bool>,
reconnectionAttempts: option<int>,
connectionCallback: option<(~error: array<Js.Exn.t>, ~result: option<Js.Json.t>) => unit>,
connectionParams?: ConnectionParamsOptions.Js_.t,
timeout?: int,
reconnect?: bool,
reconnectionAttempts?: int,
connectionCallback?: (~error: array<Js.Exn.t>, ~result: option<Js.Json.t>) => unit,
@as("lazy")
lazy_: option<bool>,
inactivityTimeout: option<int>,
lazy_?: bool,
inactivityTimeout?: int,
}
}

type t = {
connectionParams: option<ConnectionParamsOptions.t>,
timeout: option<int>,
reconnect: option<bool>,
reconnectionAttempts: option<int>,
connectionCallback: option<(~error: array<Js.Exn.t>, ~result: option<Js.Json.t>) => unit>,
connectionParams?: ConnectionParamsOptions.t,
timeout?: int,
reconnect?: bool,
reconnectionAttempts?: int,
connectionCallback?: (~error: array<Js.Exn.t>, ~result: option<Js.Json.t>) => unit,
@as("lazy")
lazy_: option<bool>,
inactivityTimeout: option<int>,
lazy_?: bool,
inactivityTimeout?: int,
}

let toJs: t => Js_.t = t => {
connectionParams: t.connectionParams->Belt.Option.map(ConnectionParamsOptions.toJs),
timeout: t.timeout,
reconnect: t.reconnect,
reconnectionAttempts: t.reconnectionAttempts,
connectionCallback: t.connectionCallback,
lazy_: t.lazy_,
inactivityTimeout: t.inactivityTimeout,
connectionParams: ?t.connectionParams->Belt.Option.map(ConnectionParamsOptions.toJs),
timeout: ?t.timeout,
reconnect: ?t.reconnect,
reconnectionAttempts: ?t.reconnectionAttempts,
connectionCallback: ?t.connectionCallback,
lazy_: ?t.lazy_,
inactivityTimeout: ?t.inactivityTimeout,
}

let make = (
Expand All @@ -126,13 +126,13 @@ module ClientOptions = {
~inactivityTimeout=?,
(),
): t => {
connectionParams: connectionParams,
timeout: timeout,
reconnect: reconnect,
reconnectionAttempts: reconnectionAttempts,
connectionCallback: connectionCallback,
lazy_: lazy_,
inactivityTimeout: inactivityTimeout,
connectionParams: ?connectionParams,
timeout: ?timeout,
reconnect: ?reconnect,
reconnectionAttempts: ?reconnectionAttempts,
connectionCallback: ?connectionCallback,
lazy_: ?lazy_,
inactivityTimeout: ?inactivityTimeout,
}
}

Expand Down

0 comments on commit d9274dd

Please sign in to comment.