From 9b9427e49faf09b52bd0f92f438935501b0db0c8 Mon Sep 17 00:00:00 2001 From: rob Date: Mon, 5 Feb 2024 23:26:10 -0500 Subject: [PATCH] run: rescript format -all --- .github/workflows/tests.yml | 3 +- package.json | 1 + .../core/ApolloClient__Cache_Core_Cache.res | 120 +++++---- .../ApolloClient__Cache_InMemory_Policies.res | 10 +- .../core/ApolloClient__Core_ApolloClient.res | 250 +++++++++--------- .../client/core/ApolloClient__Core_Types.res | 27 +- .../ApolloClient__Core_WatchQueryOptions.res | 41 ++- .../ApolloClient__Errors_ApolloError.res | 8 +- .../core/ApolloClient__Link_Core_Types.res | 6 +- .../http/ApolloClient__Link_Http_HttpLink.res | 14 +- .../ApolloClient__Link_Retry_RetryLink.res | 4 +- .../client/link/ws/ApolloClient__Link_Ws.res | 4 +- ...ApolloClient__React_Hooks_UseLazyQuery.res | 48 ++-- .../ApolloClient__React_Hooks_UseMutation.res | 48 ++-- .../ApolloClient__React_Hooks_UseQuery.res | 30 +-- ...lloClient__React_Hooks_UseSubscription.res | 14 +- .../react/types/ApolloClient__React_Types.res | 158 ++++++----- .../testing/ApolloClient__Testing_Types.res | 2 +- src/ApolloClient__Utils.res | 2 +- ...ApolloClient__SubscriptionsTransportWs.res | 14 +- 20 files changed, 405 insertions(+), 399 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8ef10fe..5e1611d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,8 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2-beta with: - node-version: "12" + node-version: "18" registry-url: "https://registry.npmjs.org" - run: npm install + - run: npm run format:ci - run: npm run build diff --git a/package.json b/package.json index 9dcaf73..510d669 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "scripts": { "build": "rescript build -with-deps", "clean": "rescript clean", + "format:ci": "rescript format -check -all", "start": "rescript build -with-deps -w", "test": "jest" }, diff --git a/src/@apollo/client/cache/core/ApolloClient__Cache_Core_Cache.res b/src/@apollo/client/cache/core/ApolloClient__Cache_Core_Cache.res index cd97cb9..d454c29 100644 --- a/src/@apollo/client/cache/core/ApolloClient__Cache_Core_Cache.res +++ b/src/@apollo/client/cache/core/ApolloClient__Cache_Core_Cache.res @@ -186,11 +186,11 @@ module ApolloCache = { js ->Js_.readFragment( ~options={ - id: id, + id, fragment: Fragment.query, - fragmentName: fragmentName, - optimistic: optimistic, - canonizeResults: canonizeResults, + fragmentName, + optimistic, + canonizeResults, }, ~optimistic?, (), @@ -218,11 +218,11 @@ module ApolloCache = { ->Js_.readQuery( ~options=DataProxy.ReadQueryOptions.toJs( { - id: id, + id, query: Operation.query, - variables: variables, - optimistic: optimistic, - canonizeResults: canonizeResults, + variables, + optimistic, + canonizeResults, }, ~mapJsVariables, ~serializeVariables=Operation.serializeVariables, @@ -247,12 +247,12 @@ module ApolloCache = { js->Js_.writeFragment( ~options=DataProxy.WriteFragmentOptions.toJs( { - broadcast: broadcast, - data: data, - id: id, + broadcast, + data, + id, fragment: Fragment.query, - fragmentName: fragmentName, - overwrite: overwrite, + fragmentName, + overwrite, }, ~serialize=Fragment.serialize, ), @@ -275,12 +275,12 @@ module ApolloCache = { js->Js_.writeQuery( ~options=DataProxy.WriteQueryOptions.toJs( { - broadcast: broadcast, - data: data, - id: id, + broadcast, + data, + id, query: Operation.query, - variables: variables, - overwrite: overwrite, + variables, + overwrite, }, ~mapJsVariables, ~serialize=Operation.serialize, @@ -307,25 +307,27 @@ module ApolloCache = { let safeParse = Utils.safeParse(Operation.parse) js - ->Js_.updateQuery(~options=DataProxy.UpdateQueryOptions.toJs( - { - optimistic: optimistic, - canonizeResults: canonizeResults, - broadcast: broadcast, - id: id, - query: Operation.query, - variables: variables, - overwrite: overwrite, - }, - ~mapJsVariables, - ~serializeVariables=Operation.serializeVariables, - ), ~update=jsData => - jsData - ->Js.nullToOption - ->Belt.Option.map(Operation.parse) - ->update - ->Belt.Option.map(Operation.serialize) - ->Js.Nullable.fromOption + ->Js_.updateQuery( + ~options=DataProxy.UpdateQueryOptions.toJs( + { + optimistic, + canonizeResults, + broadcast, + id, + query: Operation.query, + variables, + overwrite, + }, + ~mapJsVariables, + ~serializeVariables=Operation.serializeVariables, + ), + ~update=jsData => + jsData + ->Js.nullToOption + ->Belt.Option.map(Operation.parse) + ->update + ->Belt.Option.map(Operation.serialize) + ->Js.Nullable.fromOption, ) ->Js.toOption ->Belt.Option.map(safeParse) @@ -346,21 +348,23 @@ module ApolloCache = { let safeParse = Utils.safeParse(Fragment.parse) js - ->Js_.updateFragment(~options=DataProxy.UpdateFragmentOptions.toJs({ - optimistic: optimistic, - canonizeResults: canonizeResults, - broadcast: broadcast, - id: id, - fragment: Fragment.query, - fragmentName: fragmentName, - overwrite: overwrite, - }), ~update=jsData => - jsData - ->Js.nullToOption - ->Belt.Option.map(Fragment.parse) - ->update - ->Belt.Option.map(Fragment.serialize) - ->Js.Nullable.fromOption + ->Js_.updateFragment( + ~options=DataProxy.UpdateFragmentOptions.toJs({ + optimistic, + canonizeResults, + broadcast, + id, + fragment: Fragment.query, + fragmentName, + overwrite, + }), + ~update=jsData => + jsData + ->Js.nullToOption + ->Belt.Option.map(Fragment.parse) + ->update + ->Belt.Option.map(Fragment.serialize) + ->Js.Nullable.fromOption, ) ->Js.toOption ->Belt.Option.map(safeParse) @@ -369,12 +373,12 @@ module ApolloCache = { preserveJsPropsAndContext( js, { - readFragment: readFragment, - readQuery: readQuery, - writeFragment: writeFragment, - writeQuery: writeQuery, - updateFragment: updateFragment, - updateQuery: updateQuery, + readFragment, + readQuery, + writeFragment, + writeQuery, + updateFragment, + updateQuery, }, ) } diff --git a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies.res b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies.res index fd5bfe2..f0c641a 100644 --- a/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies.res +++ b/src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_Policies.res @@ -126,11 +126,11 @@ module TypePolicy = { ~subscriptionType: bool=?, unit, ) => t = (~fields=?, ~keyFields=?, ~mutationType=?, ~queryType=?, ~subscriptionType=?, ()) => { - fields: fields, - keyFields: keyFields, - mutationType: mutationType, - queryType: queryType, - subscriptionType: subscriptionType, + fields, + keyFields, + mutationType, + queryType, + subscriptionType, } } diff --git a/src/@apollo/client/core/ApolloClient__Core_ApolloClient.res b/src/@apollo/client/core/ApolloClient__Core_ApolloClient.res index 40059f5..9b70741 100644 --- a/src/@apollo/client/core/ApolloClient__Core_ApolloClient.res +++ b/src/@apollo/client/core/ApolloClient__Core_ApolloClient.res @@ -54,9 +54,9 @@ module DefaultWatchQueryOptions = { } let make = (~fetchPolicy=?, ~errorPolicy=?, ~context=?, ()) => { - fetchPolicy: fetchPolicy, - errorPolicy: errorPolicy, - context: context, + fetchPolicy, + errorPolicy, + context, } } @@ -85,9 +85,9 @@ module DefaultQueryOptions = { } let make = (~fetchPolicy=?, ~errorPolicy=?, ~context=?, ()) => { - fetchPolicy: fetchPolicy, - errorPolicy: errorPolicy, - context: context, + fetchPolicy, + errorPolicy, + context, } } @@ -131,11 +131,11 @@ module DefaultMutateOptions = { ~refetchQueries=?, (), ) => { - context: context, - fetchPolicy: fetchPolicy, - awaitRefetchQueries: awaitRefetchQueries, - errorPolicy: errorPolicy, - refetchQueries: refetchQueries, + context, + fetchPolicy, + awaitRefetchQueries, + errorPolicy, + refetchQueries, } } @@ -171,9 +171,9 @@ module DefaultOptions = { ~watchQuery: DefaultWatchQueryOptions.t=?, unit, ) => t = (~mutate=?, ~query=?, ~watchQuery=?, ()) => { - watchQuery: watchQuery, - query: query, - mutate: mutate, + watchQuery, + query, + mutate, } } @@ -610,22 +610,22 @@ let make: ( ) => { let jsClient = Js_.make( ApolloClientOptions.toJs({ - uri: uri, - credentials: credentials, - headers: headers, - link: link, - cache: cache, - ssrForceFetchDelay: ssrForceFetchDelay, - ssrMode: ssrMode, - connectToDevTools: connectToDevTools, - queryDeduplication: queryDeduplication, - defaultOptions: defaultOptions, - assumeImmutableResults: assumeImmutableResults, - resolvers: resolvers, - typeDefs: typeDefs, - fragmentMatcher: fragmentMatcher, - name: name, - version: version, + uri, + credentials, + headers, + link, + cache, + ssrForceFetchDelay, + ssrMode, + connectToDevTools, + queryDeduplication, + defaultOptions, + assumeImmutableResults, + resolvers, + typeDefs, + fragmentMatcher, + name, + version, }), ) @@ -661,16 +661,16 @@ let make: ( jsClient, ~options=MutationOptions.toJs( { - awaitRefetchQueries: awaitRefetchQueries, - context: context, - errorPolicy: errorPolicy, - fetchPolicy: fetchPolicy, + awaitRefetchQueries, + context, + errorPolicy, + fetchPolicy, mutation: Operation.query, - optimisticResponse: optimisticResponse, - updateQueries: updateQueries, - refetchQueries: refetchQueries, - update: update, - variables: variables, + optimisticResponse, + updateQueries, + refetchQueries, + update, + variables, }, ~mapJsVariables, ~safeParse, @@ -721,11 +721,11 @@ let make: ( jsClient, ~options=QueryOptions.toJs( { - fetchPolicy: fetchPolicy, + fetchPolicy, query: Operation.query, - variables: variables, - errorPolicy: errorPolicy, - context: context, + variables, + errorPolicy, + context, }, ~mapJsVariables, ~serializeVariables=Operation.serializeVariables, @@ -767,11 +767,11 @@ let make: ( jsClient ->Js_.readFragment( ~options={ - id: id, + id, fragment: Fragment.query, - fragmentName: fragmentName, - optimistic: optimistic, - canonizeResults: canonizeResults, + fragmentName, + optimistic, + canonizeResults, }, ~optimistic?, (), @@ -799,11 +799,11 @@ let make: ( jsClient, ~options=DataProxy.ReadQueryOptions.toJs( { - id: id, + id, query: Operation.query, - variables: variables, - optimistic: optimistic, - canonizeResults: canonizeResults, + variables, + optimistic, + canonizeResults, }, ~mapJsVariables, ~serializeVariables=Operation.serializeVariables, @@ -848,11 +848,11 @@ let make: ( jsClient, ~options=SubscriptionOptions.toJs( { - fetchPolicy: fetchPolicy, + fetchPolicy, query: Operation.query, - variables: variables, - errorPolicy: errorPolicy, - context: context, + variables, + errorPolicy, + context, }, ~mapJsVariables, ~serializeVariables=Operation.serializeVariables, @@ -904,13 +904,13 @@ let make: ( ->Js_.watchQuery( ~options=WatchQueryOptions.toJs( { - fetchPolicy: fetchPolicy, - nextFetchPolicy: nextFetchPolicy, + fetchPolicy, + nextFetchPolicy, query: Operation.query, - variables: variables, - errorPolicy: errorPolicy, - context: context, - pollInterval: pollInterval, + variables, + errorPolicy, + context, + pollInterval, }, ~mapJsVariables, ~serializeVariables=Operation.serializeVariables, @@ -932,12 +932,12 @@ let make: ( jsClient->Js_.writeFragment( ~options=DataProxy.WriteFragmentOptions.toJs( { - broadcast: broadcast, - data: data, - id: id, + broadcast, + data, + id, fragment: Fragment.query, - fragmentName: fragmentName, - overwrite: overwrite, + fragmentName, + overwrite, }, ~serialize=Fragment.serialize, ), @@ -960,12 +960,12 @@ let make: ( jsClient->Js_.writeQuery( ~options=DataProxy.WriteQueryOptions.toJs( { - broadcast: broadcast, - data: data, - id: id, + broadcast, + data, + id, query: Operation.query, - variables: variables, - overwrite: overwrite, + variables, + overwrite, }, ~mapJsVariables, ~serialize=Operation.serialize, @@ -992,25 +992,27 @@ let make: ( let safeParse = Utils.safeParse(Operation.parse) jsClient - ->Js_.updateQuery(~options=DataProxy.UpdateQueryOptions.toJs( - { - optimistic: optimistic, - canonizeResults: canonizeResults, - broadcast: broadcast, - id: id, - query: Operation.query, - variables: variables, - overwrite: overwrite, - }, - ~mapJsVariables, - ~serializeVariables=Operation.serializeVariables, - ), ~update=jsData => - jsData - ->Js.nullToOption - ->Belt.Option.map(Operation.parse) - ->update - ->Belt.Option.map(Operation.serialize) - ->Js.Nullable.fromOption + ->Js_.updateQuery( + ~options=DataProxy.UpdateQueryOptions.toJs( + { + optimistic, + canonizeResults, + broadcast, + id, + query: Operation.query, + variables, + overwrite, + }, + ~mapJsVariables, + ~serializeVariables=Operation.serializeVariables, + ), + ~update=jsData => + jsData + ->Js.nullToOption + ->Belt.Option.map(Operation.parse) + ->update + ->Belt.Option.map(Operation.serialize) + ->Js.Nullable.fromOption, ) ->Js.toOption ->Belt.Option.map(safeParse) @@ -1031,21 +1033,23 @@ let make: ( let safeParse = Utils.safeParse(Fragment.parse) jsClient - ->Js_.updateFragment(~options=DataProxy.UpdateFragmentOptions.toJs({ - optimistic: optimistic, - canonizeResults: canonizeResults, - broadcast: broadcast, - id: id, - fragment: Fragment.query, - fragmentName: fragmentName, - overwrite: overwrite, - }), ~update=jsData => - jsData - ->Js.nullToOption - ->Belt.Option.map(Fragment.parse) - ->update - ->Belt.Option.map(Fragment.serialize) - ->Js.Nullable.fromOption + ->Js_.updateFragment( + ~options=DataProxy.UpdateFragmentOptions.toJs({ + optimistic, + canonizeResults, + broadcast, + id, + fragment: Fragment.query, + fragmentName, + overwrite, + }), + ~update=jsData => + jsData + ->Js.nullToOption + ->Belt.Option.map(Fragment.parse) + ->update + ->Belt.Option.map(Fragment.serialize) + ->Js.Nullable.fromOption, ) ->Js.toOption ->Belt.Option.map(safeParse) @@ -1054,24 +1058,24 @@ let make: ( preserveJsPropsAndContext( jsClient, { - clearStore: clearStore, - extract: extract, - mutate: mutate, - onClearStore: onClearStore, - onResetStore: onResetStore, - query: query, - readFragment: readFragment, - readQuery: readQuery, - resetStore: resetStore, - restore: restore, - setLink: setLink, - stop: stop, - subscribe: subscribe, - watchQuery: watchQuery, - writeFragment: writeFragment, - writeQuery: writeQuery, - updateQuery: updateQuery, - updateFragment: updateFragment, + clearStore, + extract, + mutate, + onClearStore, + onResetStore, + query, + readFragment, + readQuery, + resetStore, + restore, + setLink, + stop, + subscribe, + watchQuery, + writeFragment, + writeQuery, + updateQuery, + updateFragment, }, ) } diff --git a/src/@apollo/client/core/ApolloClient__Core_Types.res b/src/@apollo/client/core/ApolloClient__Core_Types.res index b3152a8..a212efc 100644 --- a/src/@apollo/client/core/ApolloClient__Core_Types.res +++ b/src/@apollo/client/core/ApolloClient__Core_Types.res @@ -82,8 +82,8 @@ module ApolloQueryResult = { ) { - data: data, - error: error, + data, + error, loading: js.loading, networkStatus: js.networkStatus->NetworkStatus.fromJs, } @@ -107,7 +107,7 @@ module ApolloQueryResult = { switch apolloQueryResult { | {data: Some(data)} => Ok({ - data: data, + data, error: apolloQueryResult.error, loading: apolloQueryResult.loading, networkStatus: apolloQueryResult.networkStatus, @@ -150,17 +150,16 @@ module MutationQueryReducer = { let toJs: ( t<'data>, ~safeParse: Types.safeParse<'data, 'jsData>, - . Js.Json.t, - Js_.options<'jsData>, - ) => Js.Json.t = (t, ~safeParse, . previousResult, jsOptions) => - t( - previousResult, - { - mutationResult: jsOptions.mutationResult->FetchResult.fromJs(~safeParse), - queryName: jsOptions.queryName, - queryVariables: jsOptions.queryVariables, - }, - ) + ) => (. Js.Json.t, Js_.options<'jsData>) => Js.Json.t = (t, ~safeParse) => + (. previousResult, jsOptions) => + t( + previousResult, + { + mutationResult: jsOptions.mutationResult->FetchResult.fromJs(~safeParse), + queryName: jsOptions.queryName, + queryVariables: jsOptions.queryVariables, + }, + ) } module MutationQueryReducersMap = { diff --git a/src/@apollo/client/core/ApolloClient__Core_WatchQueryOptions.res b/src/@apollo/client/core/ApolloClient__Core_WatchQueryOptions.res index 7ac57ea..4c43f9a 100644 --- a/src/@apollo/client/core/ApolloClient__Core_WatchQueryOptions.res +++ b/src/@apollo/client/core/ApolloClient__Core_WatchQueryOptions.res @@ -198,24 +198,23 @@ module UpdateQueryFn = { ~querySafeParse, ~querySerialize, ~subscriptionSafeParse, - . jsQueryData, - {subscriptionData: {data}}, ) => - switch (jsQueryData->querySafeParse, data->subscriptionSafeParse) { - | (Ok(queryData), Ok(subscriptionData)) => - t( - queryData, - { - subscriptionData: { - data: subscriptionData, + (. jsQueryData, {subscriptionData: {data}}) => + switch (jsQueryData->querySafeParse, data->subscriptionSafeParse) { + | (Ok(queryData), Ok(subscriptionData)) => + t( + queryData, + { + subscriptionData: { + data: subscriptionData, + }, }, - }, - )->querySerialize - | (Error(parseError), _) - | (_, Error(parseError)) => - onParseError(parseError) - jsQueryData - } + )->querySerialize + | (Error(parseError), _) + | (_, Error(parseError)) => + onParseError(parseError) + jsQueryData + } } module SubscribeToMoreOptions = { @@ -326,9 +325,9 @@ module MutationUpdaterFn = { let toJs: (t<'data>, ~safeParse: Types.safeParse<'data, 'jsData>) => Js_.t<'jsData> = ( mutationUpdaterFn, ~safeParse, - . cache, - jsFetchResult, - ) => mutationUpdaterFn(cache, jsFetchResult->FetchResult.fromJs(~safeParse)) + ) => + (. cache, jsFetchResult) => + mutationUpdaterFn(cache, jsFetchResult->FetchResult.fromJs(~safeParse)) } module RefetchQueryDescription = { @@ -418,8 +417,8 @@ module MutationOptions = { 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, . variables) => - optimisticResponse(variables)->serialize + 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)), diff --git a/src/@apollo/client/errors/ApolloClient__Errors_ApolloError.res b/src/@apollo/client/errors/ApolloClient__Errors_ApolloError.res index 477bd02..05855a2 100644 --- a/src/@apollo/client/errors/ApolloClient__Errors_ApolloError.res +++ b/src/@apollo/client/errors/ApolloClient__Errors_ApolloError.res @@ -161,11 +161,11 @@ let make: ( unit, ) => t = (~graphQLErrors=?, ~networkError=?, ~errorMessage=?, ~extraInfo=?, ()) => { let errorWithoutNetworkError = Js_.make({ - graphQLErrors: graphQLErrors, + graphQLErrors, networkError: Js.Nullable.undefined, - errorMessage: errorMessage, - extraInfo: extraInfo, + errorMessage, + extraInfo, })->fromJs - {...errorWithoutNetworkError, networkError: networkError} + {...errorWithoutNetworkError, networkError} } diff --git a/src/@apollo/client/link/core/ApolloClient__Link_Core_Types.res b/src/@apollo/client/link/core/ApolloClient__Link_Core_Types.res index ce23ea6..62526af 100644 --- a/src/@apollo/client/link/core/ApolloClient__Link_Core_Types.res +++ b/src/@apollo/client/link/core/ApolloClient__Link_Core_Types.res @@ -118,7 +118,7 @@ module FetchResult = { ~graphQLErrors=?js.errors, safeParse, ) - {data: data, error: error, extensions: js.extensions, context: js.context} + {data, error, extensions: js.extensions, context: js.context} } let fromError: ApolloError.t => t<'data> = error => { @@ -139,7 +139,7 @@ module FetchResult = { switch fetchResult { | {data: Some(data)} => Ok({ - data: data, + data, error: fetchResult.error, extensions: fetchResult.extensions, context: fetchResult.context, @@ -180,5 +180,5 @@ module RequestHandler = { NextLink.Js_.t, ) => option, Js.Exn.t>> - let toJs: t => Js_.t = (t, . operation, forward) => t(operation, forward)->Js.Null.fromOption + let toJs: t => Js_.t = t => (. operation, forward) => t(operation, forward)->Js.Null.fromOption } diff --git a/src/@apollo/client/link/http/ApolloClient__Link_Http_HttpLink.res b/src/@apollo/client/link/http/ApolloClient__Link_Http_HttpLink.res index 6d1f0c5..c1d4f5c 100644 --- a/src/@apollo/client/link/http/ApolloClient__Link_Http_HttpLink.res +++ b/src/@apollo/client/link/http/ApolloClient__Link_Http_HttpLink.res @@ -32,11 +32,11 @@ let make: ( (), ) => Js_.make({ - uri: uri, - includeExtensions: includeExtensions, - fetch: fetch, - headers: headers, - credentials: credentials, - fetchOptions: fetchOptions, - useGETForQueries: useGETForQueries, + uri, + includeExtensions, + fetch, + headers, + credentials, + fetchOptions, + useGETForQueries, }) diff --git a/src/@apollo/client/link/retry/ApolloClient__Link_Retry_RetryLink.res b/src/@apollo/client/link/retry/ApolloClient__Link_Retry_RetryLink.res index 9f90d14..e491b0a 100644 --- a/src/@apollo/client/link/retry/ApolloClient__Link_Retry_RetryLink.res +++ b/src/@apollo/client/link/retry/ApolloClient__Link_Retry_RetryLink.res @@ -82,7 +82,7 @@ module Js_ = { let make = (~attempts=?, ~delay=?, ()) => Js_.make( Options.toJs({ - attempts: attempts, - delay: delay, + attempts, + delay, }), ) diff --git a/src/@apollo/client/link/ws/ApolloClient__Link_Ws.res b/src/@apollo/client/link/ws/ApolloClient__Link_Ws.res index 9c010df..0bfdf28 100644 --- a/src/@apollo/client/link/ws/ApolloClient__Link_Ws.res +++ b/src/@apollo/client/link/ws/ApolloClient__Link_Ws.res @@ -49,9 +49,9 @@ module WebSocketLink = { ) => ApolloLink.t = (~uri, ~options=?, ~webSocketImpl=?, ()) => Js_.make( #Configuration({ - uri: uri, + uri, options: options->Belt.Option.map(ClientOptions.toJs), - webSocketImpl: webSocketImpl, + webSocketImpl, }), ) diff --git a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseLazyQuery.res b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseLazyQuery.res index b0aa2c8..2522b49 100644 --- a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseLazyQuery.res +++ b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseLazyQuery.res @@ -64,19 +64,19 @@ let useLazyQuery: Operation.query, LazyQueryHookOptions.toJs( { - client: client, - context: context, - displayName: displayName, - errorPolicy: errorPolicy, - fetchPolicy: fetchPolicy, - nextFetchPolicy: nextFetchPolicy, - onCompleted: onCompleted, - onError: onError, - notifyOnNetworkStatusChange: notifyOnNetworkStatusChange, - partialRefetch: partialRefetch, - pollInterval: pollInterval, + client, + context, + displayName, + errorPolicy, + fetchPolicy, + nextFetchPolicy, + onCompleted, + onError, + notifyOnNetworkStatusChange, + partialRefetch, + pollInterval, query: None, - ssr: ssr, + ssr, variables: None, }, ~safeParse, @@ -141,19 +141,19 @@ let useLazyQueryWithVariables: Operation.query, LazyQueryHookOptions.toJs( { - client: client, - context: context, - displayName: displayName, - errorPolicy: errorPolicy, - fetchPolicy: fetchPolicy, - nextFetchPolicy: nextFetchPolicy, - onCompleted: onCompleted, - onError: onError, - notifyOnNetworkStatusChange: notifyOnNetworkStatusChange, - partialRefetch: partialRefetch, - pollInterval: pollInterval, + client, + context, + displayName, + errorPolicy, + fetchPolicy, + nextFetchPolicy, + onCompleted, + onError, + notifyOnNetworkStatusChange, + partialRefetch, + pollInterval, query: None, - ssr: ssr, + ssr, variables: Some(variables), }, ~safeParse, diff --git a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseMutation.res b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseMutation.res index 6cdbe10..c8ec1be 100644 --- a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseMutation.res +++ b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseMutation.res @@ -68,18 +68,18 @@ let useMutation: MutationHookOptions.toJs( { mutation: None, - awaitRefetchQueries: awaitRefetchQueries, - context: context, - client: client, - errorPolicy: errorPolicy, - fetchPolicy: fetchPolicy, - ignoreResults: ignoreResults, - notifyOnNetworkStatusChange: notifyOnNetworkStatusChange, - onError: onError, - onCompleted: onCompleted, - optimisticResponse: optimisticResponse, - refetchQueries: refetchQueries, - update: update, + awaitRefetchQueries, + context, + client, + errorPolicy, + fetchPolicy, + ignoreResults, + notifyOnNetworkStatusChange, + onError, + onCompleted, + optimisticResponse, + refetchQueries, + update, variables: None, }, ~mapJsVariables=Utils.identity, @@ -146,18 +146,18 @@ let useMutationWithVariables: MutationHookOptions.toJs( { mutation: None, - awaitRefetchQueries: awaitRefetchQueries, - context: context, - client: client, - errorPolicy: errorPolicy, - fetchPolicy: fetchPolicy, - ignoreResults: ignoreResults, - notifyOnNetworkStatusChange: notifyOnNetworkStatusChange, - onError: onError, - onCompleted: onCompleted, - optimisticResponse: optimisticResponse, - refetchQueries: refetchQueries, - update: update, + awaitRefetchQueries, + context, + client, + errorPolicy, + fetchPolicy, + ignoreResults, + notifyOnNetworkStatusChange, + onError, + onCompleted, + optimisticResponse, + refetchQueries, + update, variables: Some(variables), }, ~mapJsVariables, diff --git a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseQuery.res b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseQuery.res index 0519f8c..34cfc4a 100644 --- a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseQuery.res +++ b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseQuery.res @@ -69,21 +69,21 @@ let useQuery: Operation.query, QueryHookOptions.toJs( { - client: client, - context: context, - displayName: displayName, - errorPolicy: errorPolicy, - fetchPolicy: fetchPolicy, - nextFetchPolicy: nextFetchPolicy, - onCompleted: onCompleted, - onError: onError, - notifyOnNetworkStatusChange: notifyOnNetworkStatusChange, - partialRefetch: partialRefetch, - pollInterval: pollInterval, + client, + context, + displayName, + errorPolicy, + fetchPolicy, + nextFetchPolicy, + onCompleted, + onError, + notifyOnNetworkStatusChange, + partialRefetch, + pollInterval, query: None, - skip: skip, - ssr: ssr, - variables: variables, + skip, + ssr, + variables, }, ~mapJsVariables, ~safeParse, @@ -117,7 +117,7 @@ module Extend = (M: Operation) => { RefetchQueryDescription.PureQueryOptions({ query: M.query, variables: jsVariables, - context: context, + context, }) } diff --git a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseSubscription.res b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseSubscription.res index c3e56d7..0152842 100644 --- a/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseSubscription.res +++ b/src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseSubscription.res @@ -72,14 +72,14 @@ let useSubscription: Operation.query, SubscriptionHookOptions.toJs( { - client: client, - fetchPolicy: fetchPolicy, - onSubscriptionData: onSubscriptionData, - onSubscriptionComplete: onSubscriptionComplete, + client, + fetchPolicy, + onSubscriptionData, + onSubscriptionComplete, subscription: None, - shouldResubscribe: shouldResubscribe, - skip: skip, - variables: variables, + shouldResubscribe, + skip, + variables, }, ~mapJsVariables, ~safeParse, diff --git a/src/@apollo/client/react/types/ApolloClient__React_Types.res b/src/@apollo/client/react/types/ApolloClient__React_Types.res index d70f775..fb04961 100644 --- a/src/@apollo/client/react/types/ApolloClient__React_Types.res +++ b/src/@apollo/client/react/types/ApolloClient__React_Types.res @@ -87,8 +87,8 @@ module QueryHookOptions = { ~onCompleted=?t.onCompleted->Belt.Option.map((onCompleted, jsData) => onCompleted(jsData->safeParse) ), - ~onError=?t.onError->Belt.Option.map((onError, . jsApolloError) => - onError(ApolloError.fromJs(jsApolloError)) + ~onError=?t.onError->Belt.Option.map(onError => + (. jsApolloError) => onError(ApolloError.fromJs(jsApolloError)) ), ~fetchPolicy=?t.fetchPolicy->Belt.Option.map(WatchQueryFetchPolicy.toJs), ~nextFetchPolicy=?t.nextFetchPolicy->Belt.Option.map(WatchQueryFetchPolicy.toJs), @@ -170,8 +170,8 @@ module LazyQueryHookOptions = { ~onCompleted=?t.onCompleted->Belt.Option.map((onCompleted, jsData) => onCompleted(jsData->safeParse) ), - ~onError=?t.onError->Belt.Option.map((onError, . jsApolloError) => - onError(ApolloError.fromJs(jsApolloError)) + ~onError=?t.onError->Belt.Option.map(onError => + (. jsApolloError) => onError(ApolloError.fromJs(jsApolloError)) ), ~fetchPolicy=?t.fetchPolicy->Belt.Option.map(WatchQueryFetchPolicy.toJs), ~notifyOnNetworkStatusChange=?t.notifyOnNetworkStatusChange, @@ -384,36 +384,36 @@ module QueryResult = { ->Js_.fetchMore( Js_.t_fetchMoreOptions( ~context?, - ~updateQuery=?updateQuery->Belt.Option.map(( - updateQuery, - . previousResult, - jsFetchMoreOptions: Js_.t_fetchMoreOptions_updateQueryOptions<'jsData, 'jsVariables>, - ) => - switch ( - safeParse(previousResult), - jsFetchMoreOptions.fetchMoreResult->Belt.Option.map(safeParse), - ) { - | (Ok(previousResult), Some(Ok(fetchMoreResult))) => - updateQuery( - previousResult, - { - fetchMoreResult: Some(fetchMoreResult), - variables: jsFetchMoreOptions.variables, - }, - )->serialize - | (Ok(previousResult), None) => - updateQuery( - previousResult, - { - fetchMoreResult: None, - variables: jsFetchMoreOptions.variables, - }, - )->serialize - | (Error(parseError), _) - | (Ok(_), Some(Error(parseError))) => - parseErrorDuringCall.contents = Some(Error(parseError)) - previousResult - } + ~updateQuery=?updateQuery->Belt.Option.map(updateQuery => + (. + previousResult, + jsFetchMoreOptions: Js_.t_fetchMoreOptions_updateQueryOptions<'jsData, 'jsVariables>, + ) => + switch ( + safeParse(previousResult), + jsFetchMoreOptions.fetchMoreResult->Belt.Option.map(safeParse), + ) { + | (Ok(previousResult), Some(Ok(fetchMoreResult))) => + updateQuery( + previousResult, + { + fetchMoreResult: Some(fetchMoreResult), + variables: jsFetchMoreOptions.variables, + }, + )->serialize + | (Ok(previousResult), None) => + updateQuery( + previousResult, + { + fetchMoreResult: None, + variables: jsFetchMoreOptions.variables, + }, + )->serialize + | (Error(parseError), _) + | (Ok(_), Some(Error(parseError))) => + parseErrorDuringCall.contents = Some(Error(parseError)) + previousResult + } ), ~variables=?variables->Belt.Option.map(v => v->serializeVariables->mapJsVariables), (), @@ -483,12 +483,12 @@ module QueryResult = { SubscribeToMoreOptions.toJs( { document: Operation.query, - variables: variables, - updateQuery: updateQuery, + variables, + updateQuery, onError: onError->Belt.Option.map((onError, error) => onError(SubscriptionError(error)) ), - context: context, + context, }, ~onUpdateQueryParseError=parseError => switch onError { @@ -510,17 +510,17 @@ module QueryResult = { { called: js.called, client: js.client, - data: data, - previousData: previousData, - error: error, + data, + previousData, + error, loading: js.loading, networkStatus: js.networkStatus->NetworkStatus.fromJs, - fetchMore: fetchMore, - refetch: refetch, - startPolling: startPolling, - stopPolling: stopPolling, - subscribeToMore: subscribeToMore, - updateQuery: updateQuery, + fetchMore, + refetch, + startPolling, + stopPolling, + subscribeToMore, + updateQuery, } } } @@ -636,7 +636,7 @@ module QueryTuple = { ) => ( (~context=?, ~mapJsVariables=ApolloClient__Utils.identity, variables) => jsExecuteQuery({ - context: context, + context, variables: variables->serializeVariables->mapJsVariables, }) |> Js.Promise.then_(jsResult => QueryResult.fromJs( @@ -680,7 +680,7 @@ module QueryTuple__noVariables = { ) => ( (~context=?, ()) => jsExecuteQuery({ - context: context, + context, variables: variables->serializeVariables->mapJsVariables, }) |> Js.Promise.then_(jsResult => QueryResult.fromJs( @@ -813,8 +813,8 @@ module MutationHookOptions = { ~ignoreResults=?t.ignoreResults, ~mutation=?t.mutation, ~notifyOnNetworkStatusChange=?t.notifyOnNetworkStatusChange, - ~onError=?t.onError->Belt.Option.map((onError, . jsApolloError) => - onError(ApolloError.fromJs(jsApolloError)) + ~onError=?t.onError->Belt.Option.map(onError => + (. jsApolloError) => onError(ApolloError.fromJs(jsApolloError)) ), ~onCompleted=?t.onCompleted->Belt.Option.map((onCompleted, jsData) => onCompleted(jsData->safeParse) @@ -868,8 +868,8 @@ module MutationResult = { safeParse, ) { - data: data, - error: error, + data, + error, loading: js.loading, called: js.called, client: js.client, @@ -925,8 +925,8 @@ module MutationFunctionOptions = { ~serializeVariables, ) => { variables: t.variables->serializeVariables->mapJsVariables, - optimisticResponse: t.optimisticResponse->Belt.Option.map((optimisticResponse, . variables) => - optimisticResponse(variables)->serialize + optimisticResponse: t.optimisticResponse->Belt.Option.map(optimisticResponse => + (. variables) => optimisticResponse(variables)->serialize ), refetchQueries: t.refetchQueries->Belt.Option.map(RefetchQueryDescription.toJs), awaitRefetchQueries: t.awaitRefetchQueries, @@ -988,13 +988,13 @@ module MutationTuple = { Some( MutationFunctionOptions.toJs( { - variables: variables, - optimisticResponse: optimisticResponse, - refetchQueries: refetchQueries, - awaitRefetchQueries: awaitRefetchQueries, - update: update, - context: context, - fetchPolicy: fetchPolicy, + variables, + optimisticResponse, + refetchQueries, + awaitRefetchQueries, + update, + context, + fetchPolicy, }, ~mapJsVariables, ~safeParse, @@ -1065,13 +1065,13 @@ module MutationTuple__noVariables = { Some( MutationFunctionOptions.toJs( { - variables: variables, - optimisticResponse: optimisticResponse, - refetchQueries: refetchQueries, - awaitRefetchQueries: awaitRefetchQueries, - update: update, - context: context, - fetchPolicy: fetchPolicy, + variables, + optimisticResponse, + refetchQueries, + awaitRefetchQueries, + update, + context, + fetchPolicy, }, ~mapJsVariables, ~safeParse, @@ -1127,7 +1127,7 @@ module SubscriptionResult = { safeParse, ) - {loading: js.loading, data: data, error: error} + {loading: js.loading, data, error} } } @@ -1247,19 +1247,17 @@ module SubscriptionHookOptions = { ~subscription=?t.subscription, ~variables=t.variables->serializeVariables->mapJsVariables, ~fetchPolicy=?t.fetchPolicy, - ~shouldResubscribe=?t.shouldResubscribe->Belt.Option.map(( - shouldResubscribe, - . jsBaseSubscriptionOptions, - ) => shouldResubscribe(jsBaseSubscriptionOptions->BaseSubscriptionOptions.fromJs)), + ~shouldResubscribe=?t.shouldResubscribe->Belt.Option.map(shouldResubscribe => + (. jsBaseSubscriptionOptions) => + shouldResubscribe(jsBaseSubscriptionOptions->BaseSubscriptionOptions.fromJs) + ), ~client=?t.client, ~skip=?t.skip, - ~onSubscriptionData=?t.onSubscriptionData->Belt.Option.map(( - onSubscriptionData, - . jsOnSubscriptionDataOptions, - ) => - onSubscriptionData( - jsOnSubscriptionDataOptions->OnSubscriptionDataOptions.fromJs(~safeParse), - ) + ~onSubscriptionData=?t.onSubscriptionData->Belt.Option.map(onSubscriptionData => + (. jsOnSubscriptionDataOptions) => + onSubscriptionData( + jsOnSubscriptionDataOptions->OnSubscriptionDataOptions.fromJs(~safeParse), + ) ), ~onSubscriptionComplete=?t.onSubscriptionComplete, (), diff --git a/src/@apollo/client/testing/ApolloClient__Testing_Types.res b/src/@apollo/client/testing/ApolloClient__Testing_Types.res index 6c8b673..59c0bfa 100644 --- a/src/@apollo/client/testing/ApolloClient__Testing_Types.res +++ b/src/@apollo/client/testing/ApolloClient__Testing_Types.res @@ -32,7 +32,7 @@ let makeResult = ( data->toJson->Js.Nullable.return ), error: error->Belt.Option.mapWithDefault(Js.Nullable.null, Js.Nullable.return), - loading: loading, + loading, } mockResult(queryResult) diff --git a/src/ApolloClient__Utils.res b/src/ApolloClient__Utils.res index 56f620f..5e6dd36 100644 --- a/src/ApolloClient__Utils.res +++ b/src/ApolloClient__Utils.res @@ -11,7 +11,7 @@ external asJson: 'any => Js.Json.t = "%identity" let safeParse: ('jsData => 'data) => Types.safeParse<'data, 'jsData> = (parse, jsData) => switch parse(jsData) { | data => Ok(data) - | exception Js.Exn.Error(error) => Error({value: jsData->asJson, error: error}) + | exception Js.Exn.Error(error) => Error({value: jsData->asJson, error}) } let safeParseAndLiftToCommonResultProps: ( diff --git a/src/subscriptions-transport-ws/ApolloClient__SubscriptionsTransportWs.res b/src/subscriptions-transport-ws/ApolloClient__SubscriptionsTransportWs.res index a059733..a1f2b46 100644 --- a/src/subscriptions-transport-ws/ApolloClient__SubscriptionsTransportWs.res +++ b/src/subscriptions-transport-ws/ApolloClient__SubscriptionsTransportWs.res @@ -126,13 +126,13 @@ module ClientOptions = { ~inactivityTimeout=?, (), ): t => { - connectionParams: connectionParams, - timeout: timeout, - reconnect: reconnect, - reconnectionAttempts: reconnectionAttempts, - connectionCallback: connectionCallback, - lazy_: lazy_, - inactivityTimeout: inactivityTimeout, + connectionParams, + timeout, + reconnect, + reconnectionAttempts, + connectionCallback, + lazy_, + inactivityTimeout, } }