├── docs ├── .nojekyll ├── img │ ├── logo.png │ ├── favicon.ico │ └── small_logo.png ├── assets │ └── js │ │ ├── 1643892c.ed9e524c.js │ │ ├── 777256b9.b09fbcfb.js │ │ ├── 774.7c8c4613.js │ │ ├── c4f5d8e4.2a22f74f.js │ │ ├── main.8b8ea7e0.js.LICENSE.txt │ │ ├── 935f2afb.b95b99fe.js │ │ ├── b2dbe049.067aca93.js │ │ ├── 9beb87c2.5fb59ad0.js │ │ ├── runtime~main.b58f8f74.js │ │ └── 3b8c55ea.6167ef36.js ├── sitemap.xml ├── 404.html ├── docs │ ├── gotchas │ │ └── index.html │ └── changelog │ │ └── index.html └── index.html ├── documentationWebsite ├── docs │ ├── gotchas.md │ ├── changelog.md │ ├── installation.md │ ├── subscriptions.md │ ├── client-configuration.md │ ├── mutations.md │ ├── queries.md │ └── overview.md ├── static │ ├── .nojekyll │ └── img │ │ ├── logo.png │ │ ├── favicon.ico │ │ └── small_logo.png ├── babel.config.js ├── sidebars.js ├── .gitignore ├── src │ ├── css │ │ └── custom.css │ └── pages │ │ ├── index.js │ │ └── styles.module.css ├── README.md ├── package.json └── docusaurus.config.js ├── EXAMPLES ├── src │ ├── Ignore.res │ ├── WebpackEntry.res │ ├── index.html │ ├── caching │ │ ├── Pagination.res │ │ └── LocalStateManagement.res │ ├── fragmentsUsage │ │ ├── Fragments.res │ │ └── Query_Fragments.res │ ├── hooksUsage │ │ ├── Subscription.res │ │ ├── Query_OverlySimple.res │ │ ├── Query_Lazy.res │ │ ├── Query_Typical.res │ │ ├── Query_SubscribeToMore.res │ │ └── Mutation.res │ ├── App.res │ ├── clientUsage │ │ ├── AsyncAwait.res │ │ ├── PromiseChaining.res │ │ └── ClientBasics.res │ └── Apollo.res ├── README.md ├── webpack.config.js ├── package.json └── bsconfig.json ├── src ├── @apollo │ └── client │ │ ├── errors │ │ ├── ApolloClient__Errors.res │ │ └── __tests__ │ │ │ └── ApolloClient__Errors_ApolloError.test.js │ │ ├── link │ │ ├── retry │ │ │ ├── ApolloClient__Link_Retry.res │ │ │ ├── ApolloClient__Link_Retry_DelayFunction.res │ │ │ ├── ApolloClient__Link_Retry_RetryFunction.res │ │ │ └── ApolloClient__Link_Retry_RetryLink.res │ │ ├── utils │ │ │ ├── ApolloClient__Link_Utils.res │ │ │ └── ApolloClient__Link_Utils_ThrowServerError.res │ │ ├── core │ │ │ ├── ApolloClient__Link_Core.res │ │ │ ├── ApolloClient__Link_Core_ApolloLink.res │ │ │ └── ApolloClient__Link_Core_Types.res │ │ ├── ApolloClient__Link.res │ │ ├── http │ │ │ ├── ApolloClient__Link_Http.res │ │ │ ├── ApolloClient__Link_Http_CreateHttpLink.res │ │ │ ├── ApolloClient__Link_Http_ParseAndCheckHttpResponse.res │ │ │ ├── ApolloClient__Link_Http_HttpLink.res │ │ │ └── ApolloClient__Link_Http_SelectHttpOptionsAndBody.res │ │ ├── ws │ │ │ └── ApolloClient__Link_Ws.res │ │ ├── context │ │ │ └── ApolloClient__Link_Context.res │ │ └── error │ │ │ └── ApolloClient__Link_Error.res │ │ ├── react │ │ ├── context │ │ │ ├── ApolloClient__React_Context.res │ │ │ └── ApolloClient__React_Context_ApolloProvider.res │ │ ├── hooks │ │ │ ├── ApolloClient__React_Hooks_UseApolloClient.res │ │ │ ├── ApolloClient__React_Hooks.res │ │ │ ├── ApolloClient__React_Hooks_UseSubscription.res │ │ │ └── ApolloClient__React_Hooks_UseLazyQuery.res │ │ └── ApolloClient__React.res │ │ ├── testing │ │ ├── react │ │ │ ├── ApolloClient__Testing_React.res │ │ │ └── ApolloClient__Testing_React_MockedProvider.res │ │ ├── ApolloClient__Testing.res │ │ ├── core │ │ │ └── ApolloClient__Testing_Core.res │ │ └── ApolloClient__Testing_Types.res │ │ ├── cache │ │ ├── ApolloClient__Cache.res │ │ ├── core │ │ │ ├── ApolloClient__Cache_Core.res │ │ │ └── types │ │ │ │ ├── ApolloClient__Cache_Core_Types.res │ │ │ │ └── ApolloClient__Cache_Core_Types_Common.res │ │ └── inmemory │ │ │ ├── ApolloClient__Cache_InMemory.res │ │ │ ├── ApolloClient__Cache_InMemory_ReactiveVars.res │ │ │ ├── ApolloClient__Cache_InMemory_InMemoryCache.res │ │ │ └── ApolloClient__Cache_InMemory_Policies.res │ │ ├── utilities │ │ ├── policies │ │ │ ├── ApolloClient__Utilities_Policies.res │ │ │ └── ApolloClient__Utilities_Policies_Pagination.res │ │ ├── observables │ │ │ ├── ApolloClient__Utilities_Observables.res │ │ │ └── ApolloClient__Utilities_Observables_Observable.res │ │ ├── graphql │ │ │ ├── ApolloClient__Utilities_Graphql.res │ │ │ ├── ApolloClient__Utilities_Graphql_GetFromAst.res │ │ │ ├── ApolloClient__Utilities_Graphql_Fragments.res │ │ │ └── ApolloClient__Utilities_Graphql_StoreUtils.res │ │ └── ApolloClient__Utilities.res │ │ ├── core │ │ ├── ApolloClient__Core.res │ │ ├── ApolloClient__Core_NetworkStatus.res │ │ ├── ApolloClient__Core_LocalState.res │ │ └── ApolloClient__Core_Types.res │ │ └── ApolloClient__Client.res ├── graphql │ ├── error │ │ ├── ApolloClient__Graphql_Error.res │ │ └── ApolloClient__Graphql_Error_GraphQLError.res │ ├── execution │ │ ├── ApolloClient__Graphql_Execution.res │ │ └── ApolloClient__Graphql_Execution_Execute.res │ ├── location │ │ └── ApolloClient__Graphql_Location.res │ ├── language │ │ ├── ApolloClient__Graphql_Language.res │ │ ├── ApolloClient__Graphql_Language_Source.res │ │ └── ApolloClient__Graphql_Language_Ast.res │ └── ApolloClient__Graphql.res ├── graphql-tag │ └── ApolloClient__GraphqlTag.res ├── ApolloClient.res ├── ApolloClient__Types.res ├── ApolloClient__Utils.res ├── graphql-ws │ └── ApolloClient__GraphqlWs_Common.res └── zen-observable │ └── ApolloClient__ZenObservable.res ├── .gitattributes ├── .gitignore ├── .npmignore ├── bsconfig.json ├── README.md ├── .github └── workflows │ ├── tests.yml │ ├── releasePublish.yml │ └── prereleasePublish.yml ├── LICENSE ├── package.json └── CODE_OF_CONDUCT.md /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /documentationWebsite/docs/gotchas.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /documentationWebsite/static/.nojekyll: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /EXAMPLES/src/Ignore.res: -------------------------------------------------------------------------------- 1 | let promise: Js.Promise.t<'a> => unit = ignore 2 | -------------------------------------------------------------------------------- /docs/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeddeloh/rescript-apollo-client/HEAD/docs/img/logo.png -------------------------------------------------------------------------------- /docs/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeddeloh/rescript-apollo-client/HEAD/docs/img/favicon.ico -------------------------------------------------------------------------------- /src/@apollo/client/errors/ApolloClient__Errors.res: -------------------------------------------------------------------------------- 1 | module ApolloError = ApolloClient__Errors_ApolloError 2 | -------------------------------------------------------------------------------- /docs/img/small_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeddeloh/rescript-apollo-client/HEAD/docs/img/small_logo.png -------------------------------------------------------------------------------- /src/@apollo/client/link/retry/ApolloClient__Link_Retry.res: -------------------------------------------------------------------------------- 1 | module RetryLink = ApolloClient__Link_Retry_RetryLink 2 | -------------------------------------------------------------------------------- /src/graphql/error/ApolloClient__Graphql_Error.res: -------------------------------------------------------------------------------- 1 | module GraphQLError = ApolloClient__Graphql_Error_GraphQLError 2 | -------------------------------------------------------------------------------- /src/graphql/execution/ApolloClient__Graphql_Execution.res: -------------------------------------------------------------------------------- 1 | module Execute = ApolloClient__Graphql_Execution_Execute 2 | -------------------------------------------------------------------------------- /src/graphql/location/ApolloClient__Graphql_Location.res: -------------------------------------------------------------------------------- 1 | type sourceLocation = { 2 | line: int, 3 | column: int, 4 | } 5 | -------------------------------------------------------------------------------- /src/@apollo/client/link/utils/ApolloClient__Link_Utils.res: -------------------------------------------------------------------------------- 1 | module ThrowServerError = ApolloClient__Link_Utils_ThrowServerError 2 | -------------------------------------------------------------------------------- /documentationWebsite/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /src/@apollo/client/react/context/ApolloClient__React_Context.res: -------------------------------------------------------------------------------- 1 | module ApolloProvider = ApolloClient__React_Context_ApolloProvider 2 | -------------------------------------------------------------------------------- /src/@apollo/client/testing/react/ApolloClient__Testing_React.res: -------------------------------------------------------------------------------- 1 | module MockedProvider = ApolloClient__Testing_React_MockedProvider 2 | -------------------------------------------------------------------------------- /src/graphql/language/ApolloClient__Graphql_Language.res: -------------------------------------------------------------------------------- 1 | module Ast = ApolloClient__Graphql_Language_Ast 2 | 3 | type documentNode 4 | -------------------------------------------------------------------------------- /src/@apollo/client/cache/ApolloClient__Cache.res: -------------------------------------------------------------------------------- 1 | module Core = ApolloClient__Cache_Core 2 | module InMemory = ApolloClient__Cache_InMemory 3 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/policies/ApolloClient__Utilities_Policies.res: -------------------------------------------------------------------------------- 1 | module Pagination = ApolloClient__Utilities_Policies_Pagination 2 | -------------------------------------------------------------------------------- /documentationWebsite/static/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeddeloh/rescript-apollo-client/HEAD/documentationWebsite/static/img/logo.png -------------------------------------------------------------------------------- /documentationWebsite/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeddeloh/rescript-apollo-client/HEAD/documentationWebsite/static/img/favicon.ico -------------------------------------------------------------------------------- /src/@apollo/client/utilities/observables/ApolloClient__Utilities_Observables.res: -------------------------------------------------------------------------------- 1 | module Observable = ApolloClient__Utilities_Observables_Observable 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.re linguist-language=Reason 2 | *.rei linguist-language=Reason 3 | *.res linguist-language=ReScript 4 | *.resi linguist-language=ReScript 5 | -------------------------------------------------------------------------------- /src/@apollo/client/cache/core/ApolloClient__Cache_Core.res: -------------------------------------------------------------------------------- 1 | module Cache = ApolloClient__Cache_Core_Cache 2 | module Types = ApolloClient__Cache_Core_Types 3 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/observables/ApolloClient__Utilities_Observables_Observable.res: -------------------------------------------------------------------------------- 1 | module Observable = ApolloClient__ZenObservable.Observable 2 | -------------------------------------------------------------------------------- /src/graphql-tag/ApolloClient__GraphqlTag.res: -------------------------------------------------------------------------------- 1 | @module("@apollo/client") 2 | external gql: string => ApolloClient__Graphql.Language.documentNode = "gql" 3 | -------------------------------------------------------------------------------- /documentationWebsite/static/img/small_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeddeloh/rescript-apollo-client/HEAD/documentationWebsite/static/img/small_logo.png -------------------------------------------------------------------------------- /src/@apollo/client/link/core/ApolloClient__Link_Core.res: -------------------------------------------------------------------------------- 1 | module ApolloLink = ApolloClient__Link_Core_ApolloLink 2 | module Types = ApolloClient__Link_Core_Types 3 | -------------------------------------------------------------------------------- /src/ApolloClient.res: -------------------------------------------------------------------------------- 1 | // We provide this file as a convenience but the main module is namespaced so you can do what you want 2 | include ReasonMLCommunity__ApolloClient 3 | -------------------------------------------------------------------------------- /src/@apollo/client/cache/core/types/ApolloClient__Cache_Core_Types.res: -------------------------------------------------------------------------------- 1 | module DataProxy = ApolloClient__Cache_Core_Types_DataProxy 2 | module Common = ApolloClient__Cache_Core_Types_Common 3 | -------------------------------------------------------------------------------- /src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory.res: -------------------------------------------------------------------------------- 1 | module InMemoryCache = ApolloClient__Cache_InMemory_InMemoryCache 2 | module Policies = ApolloClient__Cache_InMemory_Policies 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .bsb.lock 2 | .merlin 3 | package-lock.json 4 | yarn.lock 5 | yarn-error.log 6 | *.bs.js 7 | .graphql_ppx_cache/ 8 | .vscode/ 9 | lib/ 10 | node_modules/ 11 | .yarn/install-state.gz -------------------------------------------------------------------------------- /docs/assets/js/1643892c.ed9e524c.js: -------------------------------------------------------------------------------- 1 | "use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[561],{1966:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]); -------------------------------------------------------------------------------- /docs/assets/js/777256b9.b09fbcfb.js: -------------------------------------------------------------------------------- 1 | "use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[296],{4061:s=>{s.exports=JSON.parse('{"name":"docusaurus-plugin-content-pages","id":"default"}')}}]); -------------------------------------------------------------------------------- /documentationWebsite/docs/changelog.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: changelog 3 | title: Changelog 4 | --- 5 | 6 | **Tags:** 7 | 8 | - :rocket: - New Feature 9 | - :boom: - Breaking Change 10 | - :bug: - Bug Fix -------------------------------------------------------------------------------- /src/@apollo/client/react/hooks/ApolloClient__React_Hooks_UseApolloClient.res: -------------------------------------------------------------------------------- 1 | module ApolloClient = ApolloClient__Core_ApolloClient 2 | 3 | @module("@apollo/client") 4 | external useApolloClient: unit => ApolloClient.t = "useApolloClient" 5 | -------------------------------------------------------------------------------- /src/@apollo/client/testing/ApolloClient__Testing.res: -------------------------------------------------------------------------------- 1 | module Core = ApolloClient__Testing_Core 2 | module Types = ApolloClient__Testing_Types 3 | module MockedProvider = ApolloClient__Testing_React.MockedProvider 4 | 5 | let makeResult = Types.makeResult 6 | -------------------------------------------------------------------------------- /EXAMPLES/src/WebpackEntry.res: -------------------------------------------------------------------------------- 1 | @@warning("-3") 2 | switch ReactDOM.querySelector("#root") { 3 | | Some(el) => 4 | ReactDOM.render( 5 | 6 | 7 | , 8 | el, 9 | ) 10 | | None => () 11 | } 12 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/graphql/ApolloClient__Utilities_Graphql.res: -------------------------------------------------------------------------------- 1 | module Fragments = ApolloClient__Utilities_Graphql_Fragments 2 | module GetFromAst = ApolloClient__Utilities_Graphql_GetFromAst 3 | module StoreUtils = ApolloClient__Utilities_Graphql_StoreUtils 4 | -------------------------------------------------------------------------------- /documentationWebsite/sidebars.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | docs: [ 3 | { 4 | "Getting Started ": ["overview", "installation", "client-configuration"], 5 | }, 6 | { 7 | Fetching: ["queries", "mutations", "subscriptions"], 8 | }, 9 | ], 10 | }; 11 | -------------------------------------------------------------------------------- /src/@apollo/client/link/ApolloClient__Link.res: -------------------------------------------------------------------------------- 1 | module Context = ApolloClient__Link_Context 2 | module Core = ApolloClient__Link_Core 3 | module Error = ApolloClient__Link_Error 4 | module Http = ApolloClient__Link_Http 5 | module Utils = ApolloClient__Link_Utils 6 | module Ws = ApolloClient__Link_Ws 7 | -------------------------------------------------------------------------------- /EXAMPLES/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | rescript-apollo-client Examples 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/@apollo/client/react/hooks/ApolloClient__React_Hooks.res: -------------------------------------------------------------------------------- 1 | module UseApolloClient = ApolloClient__React_Hooks_UseApolloClient 2 | module UseMutation = ApolloClient__React_Hooks_UseMutation 3 | module UseQuery = ApolloClient__React_Hooks_UseQuery 4 | module UseSubscription = ApolloClient__React_Hooks_UseSubscription 5 | -------------------------------------------------------------------------------- /src/@apollo/client/testing/core/ApolloClient__Testing_Core.res: -------------------------------------------------------------------------------- 1 | module Link = ApolloClient__Link_Core_ApolloLink 2 | module Types = ApolloClient__Testing_Types 3 | 4 | @new @module("@apollo/client/testing") 5 | external mockLink: (~mocks: array>, ~addTypename: bool) => Link.t = 6 | "MockLink" 7 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/graphql/ApolloClient__Utilities_Graphql_GetFromAst.res: -------------------------------------------------------------------------------- 1 | module Graphql = ApolloClient__Graphql 2 | 3 | @module("@apollo/client/utilities") 4 | external getOperationDefinition: Graphql.documentNode => option< 5 | Graphql.Language.Ast.OperationDefinitionNode.t, 6 | > = "getOperationDefinition" 7 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/ApolloClient__Utilities.res: -------------------------------------------------------------------------------- 1 | let getOperationDefinition = ApolloClient__Utilities_Graphql_GetFromAst.getOperationDefinition 2 | 3 | module Graphql = ApolloClient__Utilities_Graphql 4 | module Observables = ApolloClient__Utilities_Observables 5 | module Policies = ApolloClient__Utilities_Policies 6 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/graphql/ApolloClient__Utilities_Graphql_Fragments.res: -------------------------------------------------------------------------------- 1 | module FragmentDefinitionNode = ApolloClient__Graphql.Language.Ast.FragmentDefinitionNode 2 | 3 | module FragmentMap = { 4 | module Js_ = { 5 | type t = Js.Dict.t 6 | } 7 | 8 | type t = Js_.t 9 | } 10 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/graphql/ApolloClient__Utilities_Graphql_StoreUtils.res: -------------------------------------------------------------------------------- 1 | module StoreValue = { 2 | type t // Please contribute if you need this! 3 | module Js_ = { 4 | // export declare type StoreValue = number | string | string[] | Reference | Reference[] | null | undefined | void | Object; 5 | type t = t 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/@apollo/client/link/http/ApolloClient__Link_Http.res: -------------------------------------------------------------------------------- 1 | module CreateHttpLink = ApolloClient__Link_Http_CreateHttpLink 2 | module HttpLink = ApolloClient__Link_Http_HttpLink 3 | module ParseAndCheckHttpResponse = ApolloClient__Link_Http_ParseAndCheckHttpResponse 4 | module SelectHttpOptionsAndBody = ApolloClient__Link_Http_SelectHttpOptionsAndBody 5 | -------------------------------------------------------------------------------- /src/graphql/ApolloClient__Graphql.res: -------------------------------------------------------------------------------- 1 | module Error = ApolloClient__Graphql_Error 2 | module Execution = ApolloClient__Graphql_Execution 3 | module GraphQLError = ApolloClient__Graphql_Error_GraphQLError 4 | module Language = ApolloClient__Graphql_Language 5 | module Location = ApolloClient__Graphql_Location 6 | 7 | type documentNode = Language.documentNode 8 | -------------------------------------------------------------------------------- /documentationWebsite/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | **/__tests__/** 2 | .bsb.lock 3 | *.bs.js 4 | .gitattributes 5 | .github/ 6 | .graphql_ppx_cache/ 7 | .merlin 8 | .vscode/ 9 | assets/ 10 | CONTRIBUTING.md 11 | CODE_OF_CONDUCT.md 12 | documentation/ 13 | documentationWebsite/ 14 | docs/ 15 | EXAMPLES/ 16 | lib/ 17 | node_modules/ 18 | package-lock.json 19 | TODO 20 | yarn.lock 21 | yarn-error.log 22 | -------------------------------------------------------------------------------- /EXAMPLES/src/caching/Pagination.res: -------------------------------------------------------------------------------- 1 | let cache = { 2 | open ApolloClient.Cache.InMemoryCache 3 | make( 4 | ~typePolicies=[ 5 | ( 6 | "Query", 7 | TypePolicy.make( 8 | ~fields=[("somefieldName", RelayStylePagination(KeySpecifier(["key1", "key2"])))], 9 | (), 10 | ), 11 | ), 12 | ], 13 | (), 14 | ) 15 | } 16 | -------------------------------------------------------------------------------- /EXAMPLES/src/fragmentsUsage/Fragments.res: -------------------------------------------------------------------------------- 1 | %graphql( 2 | ` 3 | # Check it out! This will be exposed as a module called TodoItem! 4 | fragment TodoItem on TodoItem { 5 | id 6 | text 7 | completed 8 | } 9 | 10 | query Fragments { 11 | allTodos { 12 | ...TodoItem 13 | } 14 | } 15 | ` 16 | {inline: true} 17 | ) 18 | -------------------------------------------------------------------------------- /src/graphql/language/ApolloClient__Graphql_Language_Source.res: -------------------------------------------------------------------------------- 1 | module Location = { 2 | type t = { 3 | line: int, 4 | column: int, 5 | } 6 | } 7 | 8 | module Source = { 9 | type t = { 10 | body: string, 11 | name: string, 12 | locationOffset: Location.t, 13 | // constructor(body: string, name?: string, locationOffset?: Location); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/@apollo/client/core/ApolloClient__Core.res: -------------------------------------------------------------------------------- 1 | module ApolloClient = ApolloClient__Core_ApolloClient 2 | module LocalState = ApolloClient__Core_LocalState 3 | module NetworkStatus = ApolloClient__Core_NetworkStatus.NetworkStatus 4 | module ObservableQuery = ApolloClient__Core_ObservableQuery 5 | module Types = ApolloClient__Core_Types 6 | module WatchQueryOptions = ApolloClient__Core_WatchQueryOptions 7 | -------------------------------------------------------------------------------- /src/graphql/execution/ApolloClient__Graphql_Execution_Execute.res: -------------------------------------------------------------------------------- 1 | module GraphQLError = ApolloClient__Graphql_Error_GraphQLError 2 | 3 | module ExecutionResult = { 4 | module Js_ = { 5 | type t<'tData> = { 6 | errors: option, 7 | data: option<'tData>, 8 | } 9 | } 10 | 11 | // I don't think we want to parse this? 12 | type t<'tData> = Js_.t<'tData> 13 | } 14 | -------------------------------------------------------------------------------- /src/@apollo/client/link/http/ApolloClient__Link_Http_CreateHttpLink.res: -------------------------------------------------------------------------------- 1 | module ApolloLink = ApolloClient__Link_Core_ApolloLink 2 | module HttpOptions = ApolloClient__Link_Http_SelectHttpOptionsAndBody.HttpOptions 3 | 4 | module Js_ = { 5 | @module("@apollo/client") 6 | external createHttpLink: HttpOptions.Js_.t => ApolloLink.Js_.t = "createHttpLink" 7 | } 8 | 9 | let createHttpLink: HttpOptions.t => ApolloLink.t = Js_.createHttpLink 10 | -------------------------------------------------------------------------------- /src/@apollo/client/cache/inmemory/ApolloClient__Cache_InMemory_ReactiveVars.res: -------------------------------------------------------------------------------- 1 | module ReactiveVar = { 2 | type t<'value> = (~newValue: 'value=?, unit) => 'value 3 | 4 | module Js_ = { 5 | type t<'value> = t<'value> 6 | } 7 | } 8 | 9 | module Js_ = { 10 | @module("@apollo/client") 11 | external makeVar: 'value => ReactiveVar.Js_.t<'value> = "makeVar" 12 | } 13 | 14 | let makeVar: 'value => ReactiveVar.t<'value> = Js_.makeVar 15 | -------------------------------------------------------------------------------- /src/@apollo/client/react/ApolloClient__React.res: -------------------------------------------------------------------------------- 1 | module Context = ApolloClient__React_Context 2 | module Hooks = ApolloClient__React_Hooks 3 | module Types = ApolloClient__React_Types 4 | 5 | let useLazyQuery = ApolloClient__React_Hooks_UseLazyQuery.useLazyQuery 6 | let useMutation = ApolloClient__React_Hooks_UseMutation.useMutation 7 | let useQuery = ApolloClient__React_Hooks_UseQuery.useQuery 8 | let useSubscription = ApolloClient__React_Hooks_UseSubscription.useSubscription 9 | -------------------------------------------------------------------------------- /bsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rescript-apollo-client", 3 | "uncurried": false, 4 | "package-specs": [ 5 | { 6 | "module": "commonjs", 7 | "in-source": true 8 | } 9 | ], 10 | "jsx": { 11 | "version": 4, 12 | "mode": "automatic" 13 | }, 14 | "sources": [ 15 | { 16 | "dir": "src", 17 | "subdirs": true 18 | } 19 | ], 20 | "suffix": ".bs.js", 21 | "bs-dependencies": ["@reasonml-community/graphql-ppx", "@rescript/react"] 22 | } 23 | -------------------------------------------------------------------------------- /EXAMPLES/src/caching/LocalStateManagement.res: -------------------------------------------------------------------------------- 1 | let someLocalState = ApolloClient.Cache.makeVar("a string") 2 | 3 | let cache = { 4 | open ApolloClient.Cache.InMemoryCache 5 | make( 6 | ~typePolicies=[ 7 | ( 8 | "Query", 9 | TypePolicy.make( 10 | ~fields=[ 11 | ("someLocalStateField", FieldReadFunction((_existing, _options) => someLocalState())), 12 | ], 13 | (), 14 | ), 15 | ), 16 | ], 17 | (), 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /EXAMPLES/README.md: -------------------------------------------------------------------------------- 1 | ## Examples for `rescript-apollo-client` 2 | 3 | Here you'll find pretty sparse example of a fully functioning app and basic usage. It leverages a lightweight [example graphql server](https://github.com/zth/graphql-client-example-server) and webpack to serve app assets. 4 | 5 | #### Trying it out locally 6 | 7 | ```sh 8 | yarn 9 | 10 | yarn start 11 | # (in another tab) Run the development server 12 | yarn dev-server 13 | # (in yet another tab!) Run the example GraphQL server 14 | yarn graphql-server 15 | ``` 16 | -------------------------------------------------------------------------------- /src/@apollo/client/react/context/ApolloClient__React_Context_ApolloProvider.res: -------------------------------------------------------------------------------- 1 | module ApolloClient = ApolloClient__Core_ApolloClient 2 | 3 | // export interface ApolloProviderProps { 4 | // client: ApolloClient; 5 | // children: React.ReactNode | React.ReactNode[] | null; 6 | // } 7 | // export declare const ApolloProvider: React.FC>; 8 | @module("@apollo/client") @react.component 9 | external make: (~client: ApolloClient.t, ~children: React.element) => React.element = 10 | "ApolloProvider" 11 | -------------------------------------------------------------------------------- /EXAMPLES/src/hooksUsage/Subscription.res: -------------------------------------------------------------------------------- 1 | module SorryItsNotASubscriptionForTodos = %graphql(` 2 | subscription SorryItsNotASubscriptionForTodos { 3 | siteStatisticsUpdated { 4 | currentVisitorsOnline 5 | } 6 | } 7 | `) 8 | 9 | @react.component 10 | let make = () => <> 11 |

{"[ Not functional, but the examples are still valid ]"->React.string}

12 | {switch SorryItsNotASubscriptionForTodos.use() { 13 | | {data: Some({siteStatisticsUpdated: Some({currentVisitorsOnline})})} => 14 |

15 | {React.string("There are " ++ (string_of_int(currentVisitorsOnline) ++ " visitors online"))} 16 |

17 | | _ignoredForExample => React.null 18 | }} 19 | 20 | -------------------------------------------------------------------------------- /src/@apollo/client/core/ApolloClient__Core_NetworkStatus.res: -------------------------------------------------------------------------------- 1 | module NetworkStatus = { 2 | module Js_ = { 3 | type t = int 4 | } 5 | 6 | type t = 7 | | Loading 8 | | SetVariables 9 | | FetchMore 10 | | Refetch 11 | | Poll 12 | | Ready 13 | | Error 14 | | // Apollo types are not accurate. See: 15 | // https://github.com/reasonml-community/rescript-apollo-client/issues/68 16 | SkippedOrNotPresent 17 | 18 | let fromJs: Js_.t => t = js => 19 | switch js { 20 | | 1 => Loading 21 | | 2 => SetVariables 22 | | 3 => FetchMore 23 | | 4 => Refetch 24 | | 6 => Poll 25 | | 7 => Ready 26 | | 8 => Error 27 | | _ => SkippedOrNotPresent 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /EXAMPLES/src/hooksUsage/Query_OverlySimple.res: -------------------------------------------------------------------------------- 1 | module TodosQuery = %graphql(` 2 | query TodosQuery { 3 | todos: allTodos { 4 | id 5 | text 6 | completed 7 | } 8 | } 9 | `) 10 | 11 | @react.component 12 | let make = () => 13 | switch TodosQuery.use() { 14 | | {loading: true} => "Loading..."->React.string 15 | | {error: Some(_error)} => "Error loading data"->React.string 16 | | {data: Some({todos})} => 17 |
18 | {"There are "->React.string} 19 | {todos->Belt.Array.length->React.int} 20 | {" To-Dos"->React.string} 21 |
22 | | {data: None, error: None, loading: false} => 23 | "I hope this is impossible, but sometimes it's not!"->React.string 24 | } 25 | -------------------------------------------------------------------------------- /src/@apollo/client/link/utils/ApolloClient__Link_Utils_ThrowServerError.res: -------------------------------------------------------------------------------- 1 | /* export declare const throwServerError: (response: Response, result: any, message: string) => never */ 2 | 3 | module ServerError = { 4 | module Js_ = { 5 | // export declare type ServerError = Error & { 6 | // response: Response; 7 | // result: Record; 8 | // statusCode: number; 9 | // }; 10 | type response 11 | 12 | type t = { 13 | response: response, 14 | result: Js.Json.t, // Actual: Record; 15 | statusCode: int, 16 | // ...extends Error 17 | name: string, 18 | message: string, 19 | stack: option, 20 | } 21 | } 22 | 23 | type t = Js_.t 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Logo 3 |

4 | ReScript bindings for the Apollo Client ecosystem 5 |

6 | 7 |

8 | 9 | npm version 10 | 11 |

12 | 13 |

14 | Documentation • 15 | Installation • 16 | Examples • 17 | Contributing 18 |

19 | -------------------------------------------------------------------------------- /documentationWebsite/src/css/custom.css: -------------------------------------------------------------------------------- 1 | /* stylelint-disable docusaurus/copyright-header */ 2 | /** 3 | * Any CSS included here will be global. The classic template 4 | * bundles Infima by default. Infima is a CSS framework designed to 5 | * work well for content-centric websites. 6 | */ 7 | 8 | /* You can override the default Infima variables here. */ 9 | :root { 10 | --ifm-color-primary: #933485; 11 | --ifm-color-primary-dark: #842f78; 12 | --ifm-color-primary-darker: #7d2c71; 13 | --ifm-color-primary-darkest: #67245d; 14 | --ifm-color-primary-light: #a23992; 15 | --ifm-color-primary-lighter: #a93c99; 16 | --ifm-color-primary-lightest: #bd45ac; 17 | --ifm-code-font-size: 95%; 18 | } 19 | 20 | .white-bg { 21 | background: white; 22 | } -------------------------------------------------------------------------------- /src/@apollo/client/link/ws/ApolloClient__Link_Ws.res: -------------------------------------------------------------------------------- 1 | module ApolloLink = ApolloClient__Link_Core_ApolloLink 2 | module Graphql = ApolloClient__Graphql 3 | 4 | module WebSocketLink = { 5 | module ClientOptions = ApolloClient__GraphqlWs.ClientOptions 6 | module Client = ApolloClient__GraphqlWs.Client 7 | 8 | module Js_ = { 9 | // export class GraphQLWsLink extends ApolloLink { 10 | // constructor(public readonly client: Client); 11 | // request(operation: Operation): Observable; 12 | // } 13 | @module("@apollo/client/link/subscriptions") @new 14 | external make: Client.t => ApolloLink.Js_.t = "GraphQLWsLink" 15 | } 16 | 17 | let make: ClientOptions.t => ApolloLink.t = options => Js_.make(Client.createClient(options)) 18 | } 19 | -------------------------------------------------------------------------------- /EXAMPLES/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const HtmlWebpackPlugin = require("html-webpack-plugin"); 3 | const outputDir = path.join(__dirname, "build/"); 4 | 5 | const isProd = process.env.NODE_ENV === "production"; 6 | 7 | /** 8 | * @type import("webpack").Configuration 9 | */ 10 | module.exports = { 11 | entry: "./src/WebpackEntry.bs.js", 12 | mode: isProd ? "production" : "development", 13 | output: { 14 | path: outputDir, 15 | filename: "clientBundle.js", 16 | }, 17 | plugins: [ 18 | new HtmlWebpackPlugin({ 19 | template: "src/index.html", 20 | inject: false, 21 | }), 22 | ], 23 | devServer: { 24 | compress: true, 25 | static: { 26 | directory: outputDir, 27 | }, 28 | port: process.env.PORT || 8000, 29 | historyApiFallback: true, 30 | }, 31 | }; 32 | -------------------------------------------------------------------------------- /EXAMPLES/src/App.res: -------------------------------------------------------------------------------- 1 | @react.component 2 | let make = () => 3 | 4 |

{"Fetching Data with Hooks"->React.string}

5 |

{"Simple Query"->React.string}

6 | 7 |

{"Typical Query"->React.string}

8 | 9 |

{"Lazy Query"->React.string}

10 | 11 |

{"Mutation"->React.string}

12 | 13 |

{"Subcription"->React.string}

14 | 15 |

{"Query with Subscription for More"->React.string}

16 | 17 |

{"Fetching Data Directly with the Client"->React.string}

18 | 19 |

{"Fragments"->React.string}

20 | 21 |
22 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: tests 2 | 3 | # Controls when the action will run. Triggers the workflow on pull request 4 | on: [pull_request] 5 | 6 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 7 | jobs: 8 | # This workflow contains a single job called "Build" 9 | test-build: 10 | name: Build 11 | # The type of runner that the job will run on 12 | runs-on: ubuntu-latest 13 | # Steps represent a sequence of tasks that will be executed as part of the job 14 | steps: 15 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 16 | - uses: actions/checkout@v2 17 | - uses: actions/setup-node@v2-beta 18 | with: 19 | node-version: "18" 20 | registry-url: "https://registry.npmjs.org" 21 | - run: npm install 22 | - run: npm run format:ci 23 | - run: npm run build 24 | -------------------------------------------------------------------------------- /documentationWebsite/README.md: -------------------------------------------------------------------------------- 1 | # Website 2 | 3 | This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. 4 | 5 | ## Installation 6 | 7 | ```console 8 | yarn install 9 | ``` 10 | 11 | ## Local Development 12 | 13 | ```console 14 | yarn start 15 | ``` 16 | 17 | This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server. 18 | 19 | ## Build 20 | 21 | ```console 22 | yarn build 23 | ``` 24 | 25 | This command generates static content into the `build` directory and can be served using any static contents hosting service. 26 | 27 | ## Deployment 28 | 29 | ```console 30 | GIT_USER= USE_SSH=true yarn deploy 31 | ``` 32 | 33 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. 34 | -------------------------------------------------------------------------------- /src/@apollo/client/link/http/ApolloClient__Link_Http_ParseAndCheckHttpResponse.res: -------------------------------------------------------------------------------- 1 | // export declare function parseAndCheckHttpResponse(operations: Operation | Operation[]): (response: Response) => Promise; 2 | // export declare type ServerParseError = Error & { 3 | // response: Response; 4 | // statusCode: number; 5 | // bodyText: string; 6 | /* } */ 7 | 8 | module ServerParseError = { 9 | module Js_ = { 10 | // export declare type ServerError = Error & { 11 | // response: Response; 12 | // result: Record; 13 | // statusCode: number; 14 | // }; 15 | type response 16 | 17 | type t = { 18 | bodyText: string, 19 | response: response, 20 | statusCode: int, 21 | // ...extends Error 22 | name: string, 23 | message: string, 24 | stack: option, 25 | } 26 | } 27 | 28 | type t = Js_.t 29 | } 30 | -------------------------------------------------------------------------------- /src/@apollo/client/link/retry/ApolloClient__Link_Retry_DelayFunction.res: -------------------------------------------------------------------------------- 1 | module Operation = ApolloClient__Link_Core.Types.Operation 2 | 3 | module DelayFunction = { 4 | module Js_ = { 5 | // export interface DelayFunction { 6 | // (count: number, operation: Operation, error: any): number; 7 | // } 8 | type t = (. int, Operation.Js_.t, option) => int 9 | } 10 | 11 | type t = (~count: int, ~operation: Operation.t, ~error: option) => int 12 | 13 | let toJs: (. t) => Js_.t = (. t) => 14 | (. count, operation, error) => t(~count, ~operation=operation->Operation.fromJs, ~error) 15 | } 16 | 17 | module DelayFunctionOptions = { 18 | // export interface DelayFunctionOptions { 19 | // initial?: number; 20 | // max?: number; 21 | // jitter?: boolean; 22 | // } 23 | type t = { 24 | initial?: int, 25 | max?: int, 26 | jitter?: int, 27 | } 28 | 29 | module Js_ = { 30 | type t = t 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/@apollo/client/errors/__tests__/ApolloClient__Errors_ApolloError.test.js: -------------------------------------------------------------------------------- 1 | const { 2 | ensureApolloError, 3 | } = require("../ApolloClient__Errors_ApolloError.bs").Js_; 4 | const { ApolloError } = require("@apollo/client"); 5 | console.log(ensureApolloError); 6 | 7 | describe("dealing with garbage", () => { 8 | it("ignores proper ApolloErrors", () => { 9 | let networkError = new Error("This should be preserved"); 10 | let apolloError = new ApolloError({ networkError }); 11 | const checkedApolloError = ensureApolloError(apolloError); 12 | 13 | expect(checkedApolloError.networkError).toBe(networkError); 14 | }); 15 | 16 | it("should intelligently wrap a GrapqhQLError masquerading as ApolloError", () => { 17 | const apolloError = ensureApolloError({ 18 | message: "this is a graphql error", 19 | extensions: { code: "some_code" }, 20 | }); 21 | 22 | expect(apolloError.graphQLErrors[0].extensions.code).toBe("some_code"); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /documentationWebsite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "docusaurus": "docusaurus", 7 | "start": "docusaurus start", 8 | "build": "docusaurus build --out-dir ../docs", 9 | "swizzle": "docusaurus swizzle", 10 | "deploy": "docusaurus deploy", 11 | "serve": "docusaurus serve --dir ../docs" 12 | }, 13 | "dependencies": { 14 | "@docusaurus/core": "^2.4.3", 15 | "@docusaurus/preset-classic": "^2.4.3", 16 | "@mdx-js/react": "^1.5.8", 17 | "clsx": "^1.1.1", 18 | "react": "^16.8.4", 19 | "react-dom": "^16.8.4" 20 | }, 21 | "browserslist": { 22 | "production": [ 23 | ">0.2%", 24 | "not dead", 25 | "not op_mini all" 26 | ], 27 | "development": [ 28 | "last 1 chrome version", 29 | "last 1 firefox version", 30 | "last 1 safari version" 31 | ] 32 | }, 33 | "devDependencies": { 34 | "docusaurus": "2.0.0-alpha.66" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /EXAMPLES/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "examples", 3 | "version": "0.0.0", 4 | "description": "Examples for rescript-apollo-client", 5 | "private": true, 6 | "scripts": { 7 | "build": "rescript build -with-deps", 8 | "clean": "rescript clean", 9 | "graphql-server": "graphql-client-example-server", 10 | "server": "webpack-dev-server", 11 | "start": "rescript build -with-deps -w" 12 | }, 13 | "devDependencies": { 14 | "@reasonml-community/graphql-ppx": "1.2.4-79d140a5.0", 15 | "graphql-client-example-server": "1.5.2", 16 | "html-webpack-plugin": "5.5.0", 17 | "rescript": "11.1.4", 18 | "webpack": "5.75.0", 19 | "webpack-cli": "5.0.1", 20 | "webpack-dev-server": "^4.11.1" 21 | }, 22 | "dependencies": { 23 | "@apollo/client": "^3.13.8", 24 | "@rescript/react": "~0.11.0", 25 | "@ryyppy/rescript-promise": "2.1.0", 26 | "graphql": "^15.7.2", 27 | "react": "18.3.1", 28 | "react-dom": "18.3.1", 29 | "rescript-apollo-client": "*", 30 | "graphql-ws": "^5.5.5" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /docs/assets/js/774.7c8c4613.js: -------------------------------------------------------------------------------- 1 | "use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[774],{1774:(e,t,n)=>{n.r(t),n.d(t,{default:()=>c});var a=n(6540),l=n(1312),o=n(1003),r=n(4492);function c(){return a.createElement(a.Fragment,null,a.createElement(o.be,{title:(0,l.T)({id:"theme.NotFound.title",message:"Page Not Found"})}),a.createElement(r.A,null,a.createElement("main",{className:"container margin-vert--xl"},a.createElement("div",{className:"row"},a.createElement("div",{className:"col col--6 col--offset-3"},a.createElement("h1",{className:"hero__title"},a.createElement(l.A,{id:"theme.NotFound.title",description:"The title of the 404 page"},"Page Not Found")),a.createElement("p",null,a.createElement(l.A,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page"},"We could not find what you were looking for.")),a.createElement("p",null,a.createElement(l.A,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page"},"Please contact the owner of the site that linked you to the original URL and let them know their link is broken.")))))))}}}]); -------------------------------------------------------------------------------- /src/@apollo/client/cache/core/types/ApolloClient__Cache_Core_Types_Common.res: -------------------------------------------------------------------------------- 1 | module StoreValue = ApolloClient__Utilities_Graphql_StoreUtils.StoreValue 2 | 3 | module CanReadFunction = { 4 | type t = StoreValue.Js_.t => bool 5 | module Js_ = { 6 | // export declare type CanReadFunction = (value: StoreValue) => boolean; 7 | type t = t 8 | } 9 | } 10 | 11 | module ReadFieldFunction = { 12 | type t 13 | module Js_ = { 14 | // export interface ReadFieldFunction { 15 | // (options: ReadFieldOptions): SafeReadonly | undefined; 16 | // (fieldName: string, from?: StoreObject | Reference): SafeReadonly | undefined; 17 | // } 18 | type t = t // Please contribute if you need this! 19 | } 20 | } 21 | 22 | module ToReferenceFunction = { 23 | type t 24 | module Js_ = { 25 | // export declare type ToReferenceFunction = (objOrIdOrRef: StoreObject | string | Reference, mergeIntoStore?: boolean) => Reference | undefined; 26 | type t = t // Please contribute if you need this! 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/@apollo/client/testing/ApolloClient__Testing_Types.res: -------------------------------------------------------------------------------- 1 | module Graphql = ApolloClient__Graphql 2 | module ApolloError = ApolloClient__Errors_ApolloError 3 | 4 | type rec request<'jsVariables> = { 5 | query: Graphql.documentNode, 6 | variables: 'jsVariables, 7 | } 8 | 9 | type result 10 | 11 | type mock<'jsVariables> = { 12 | request: request<'jsVariables>, 13 | result: result, 14 | } 15 | 16 | type queryResult = { 17 | data: Js.Nullable.t, 18 | error: Js.Nullable.t, 19 | loading: bool, 20 | } 21 | 22 | external mockResult: queryResult => result = "%identity" 23 | 24 | let makeResult = ( 25 | ~data: option<'jsData>=?, 26 | ~error: option=?, 27 | ~loading=false, 28 | toJson: 'jsData => Js.Json.t, 29 | ): result => { 30 | let queryResult = { 31 | data: data->Belt.Option.mapWithDefault(Js.Nullable.null, data => 32 | data->toJson->Js.Nullable.return 33 | ), 34 | error: error->Belt.Option.mapWithDefault(Js.Nullable.null, Js.Nullable.return), 35 | loading, 36 | } 37 | 38 | mockResult(queryResult) 39 | } 40 | -------------------------------------------------------------------------------- /EXAMPLES/bsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "examples", 3 | "uncurried": false, 4 | "graphql": { 5 | "apolloMode": true, 6 | "uncurried": false, 7 | "extendMutation": "ApolloClient.GraphQL_PPX.ExtendMutation", 8 | "extendQuery": "ApolloClient.GraphQL_PPX.ExtendQuery", 9 | "extendSubscription": "ApolloClient.GraphQL_PPX.ExtendSubscription", 10 | "templateTagReturnType": "ApolloClient.GraphQL_PPX.templateTagReturnType", 11 | "templateTagImport": "gql", 12 | "templateTagLocation": "@apollo/client" 13 | }, 14 | "package-specs": [ 15 | { 16 | "module": "commonjs", 17 | "in-source": true 18 | } 19 | ], 20 | "ppx-flags": ["@reasonml-community/graphql-ppx/ppx"], 21 | "jsx": { 22 | "version": 4, 23 | "mode": "automatic" 24 | }, 25 | "sources": [ 26 | { 27 | "dir": "src", 28 | "subdirs": true 29 | } 30 | ], 31 | "suffix": ".bs.js", 32 | "bs-dependencies": [ 33 | "rescript-apollo-client", 34 | "@reasonml-community/graphql-ppx", 35 | "@ryyppy/rescript-promise", 36 | "@rescript/react" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /src/ApolloClient__Types.res: -------------------------------------------------------------------------------- 1 | module Graphql = ApolloClient__Graphql 2 | 3 | module type Fragment = { 4 | // This type is determined by the `-template-tag-return-type` ppx flag 5 | let query: Graphql.documentNode 6 | 7 | module Raw: { 8 | type t 9 | } 10 | type t 11 | 12 | let parse: Raw.t => t 13 | let serialize: t => Raw.t 14 | } 15 | 16 | module type Operation = { 17 | // This type is determined by the `-template-tag-return-type` ppx flag 18 | let query: Graphql.documentNode 19 | 20 | module Raw: { 21 | type t 22 | type t_variables 23 | } 24 | type t 25 | type t_variables 26 | 27 | let parse: Raw.t => t 28 | let serialize: t => Raw.t 29 | let serializeVariables: t_variables => Raw.t_variables 30 | } 31 | 32 | module type OperationNoRequiredVars = { 33 | include Operation 34 | let makeDefaultVariables: unit => t_variables 35 | } 36 | 37 | type parseError = { 38 | value: Js.Json.t, 39 | error: Js.Exn.t, 40 | } 41 | 42 | type parseResult<'data> = result<'data, parseError> 43 | 44 | type safeParse<'data, 'jsData> = (. 'jsData) => parseResult<'data> 45 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Meteor Development Group, Inc 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/@apollo/client/core/ApolloClient__Core_LocalState.res: -------------------------------------------------------------------------------- 1 | module ApolloCache = ApolloClient__Cache_Core_Cache.ApolloCache 2 | module FieldNode = ApolloClient__Graphql.Language.Ast.FieldNode 3 | module FragmentMap = ApolloClient__Utilities_Graphql_Fragments.FragmentMap 4 | 5 | module FragmentMatcher = { 6 | module Js_ = { 7 | // export declare type FragmentMatcher = (rootValue: any, typeCondition: string, context: any) => boolean; 8 | type t = (Js.Json.t, string, Js.Json.t) => bool 9 | } 10 | 11 | type t = Js_.t 12 | } 13 | 14 | // TODO: resolve dependency cycle 15 | type apolloClient 16 | 17 | module Resolver = { 18 | module Js_ = { 19 | type t_context = { 20 | client: apolloClient, 21 | cache: ApolloCache.t, 22 | } 23 | 24 | type t_info = { 25 | field: FieldNode.t, 26 | fragmentMap: FragmentMap.t, 27 | } 28 | 29 | // export declare type Resolver = (rootValue?: any, args?: any, context?: any, info?: { 30 | // field: FieldNode; 31 | // fragmentMap: FragmentMap; 32 | // }) => any; 33 | type t = (Js.Json.t, Js.Json.t, t_context, t_info) => Js.Json.t 34 | } 35 | 36 | type t = Js_.t 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/releasePublish.yml: -------------------------------------------------------------------------------- 1 | name: (only on release) Publish 2 | 3 | # Controls when the action will run. Triggers the workflow on push or pull request 4 | # events but only for the master branch 5 | on: 6 | push: 7 | branches: [master] 8 | release: 9 | types: [published] 10 | 11 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 12 | jobs: 13 | # This workflow contains a single job called "publish" 14 | publish: 15 | name: (only on release) Publish 16 | # The type of runner that the job will run on 17 | runs-on: ubuntu-latest 18 | # Steps represent a sequence of tasks that will be executed as part of the job 19 | steps: 20 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 21 | - uses: actions/checkout@v2 22 | - uses: actions/setup-node@v2-beta 23 | with: 24 | node-version: "12" 25 | registry-url: "https://registry.npmjs.org" 26 | 27 | - name: Publish to npm @latest 28 | if: success() && github.event_name == 'release' 29 | run: npm publish --tag=latest 30 | env: 31 | NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 32 | -------------------------------------------------------------------------------- /src/@apollo/client/link/http/ApolloClient__Link_Http_HttpLink.res: -------------------------------------------------------------------------------- 1 | module ApolloLink = ApolloClient__Link_Core_ApolloLink 2 | module HttpOptions = ApolloClient__Link_Http_SelectHttpOptionsAndBody.HttpOptions 3 | module UriFunction = ApolloClient__Link_Http_SelectHttpOptionsAndBody.UriFunction 4 | 5 | module Js_ = { 6 | // export declare class HttpLink extends ApolloLink { 7 | // options: HttpOptions; 8 | // requester: RequestHandler; 9 | // constructor(options?: HttpOptions); 10 | // } 11 | @module("@apollo/client") @new 12 | external make: HttpOptions.Js_.t => ApolloLink.Js_.t = "HttpLink" 13 | } 14 | 15 | let make: ( 16 | ~uri: UriFunction.t=?, 17 | ~includeExtensions: bool=?, 18 | ~fetch: HttpOptions.Js_.t_fetch=?, 19 | ~headers: Js.Json.t=?, 20 | ~credentials: string=?, 21 | ~fetchOptions: Js.Json.t=?, 22 | ~useGETForQueries: bool=?, 23 | unit, 24 | ) => ApolloLink.t = ( 25 | ~uri=?, 26 | ~includeExtensions=?, 27 | ~fetch=?, 28 | ~headers=?, 29 | ~credentials=?, 30 | ~fetchOptions=?, 31 | ~useGETForQueries=?, 32 | (), 33 | ) => 34 | Js_.make({ 35 | ?uri, 36 | ?includeExtensions, 37 | ?fetch, 38 | ?headers, 39 | ?credentials, 40 | ?fetchOptions, 41 | ?useGETForQueries, 42 | }) 43 | -------------------------------------------------------------------------------- /.github/workflows/prereleasePublish.yml: -------------------------------------------------------------------------------- 1 | name: (pre-release) Publish 2 | 3 | # Controls when the action will run. Triggers the workflow on push or pull request 4 | # events but only for the master branch 5 | on: 6 | push: 7 | branches: [master] 8 | 9 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 10 | jobs: 11 | # This workflow contains a single job called "publish" 12 | publish: 13 | name: (pre-release) Publish 14 | # The type of runner that the job will run on 15 | runs-on: ubuntu-latest 16 | # Steps represent a sequence of tasks that will be executed as part of the job 17 | steps: 18 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 19 | - uses: actions/checkout@v2 20 | - uses: actions/setup-node@v2-beta 21 | with: 22 | node-version: "12" 23 | registry-url: "https://registry.npmjs.org" 24 | 25 | - name: Publish to npm @dev 26 | if: success() && github.event_name != 'release' 27 | run: | 28 | npm version prerelease -preid $(git rev-parse --short HEAD) -no-git-tag-version 29 | npm publish --tag=dev 30 | env: 31 | NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} 32 | -------------------------------------------------------------------------------- /src/@apollo/client/link/context/ApolloClient__Link_Context.res: -------------------------------------------------------------------------------- 1 | module ApolloLink = ApolloClient__Link_Core_ApolloLink 2 | module GraphQLRequest = ApolloClient__Link_Core_Types.GraphQLRequest 3 | 4 | module Js_ = { 5 | // export declare type ContextSetter = (operation: GraphQLRequest, prevContext: any) => Promise | any; 6 | // export declare function setContext(setter: ContextSetter): ApolloLink; 7 | @module("@apollo/client/link/context") 8 | external setContext: ( 9 | (~operation: GraphQLRequest.t, ~prevContext: Js.Json.t) => Js.Json.t 10 | ) => ApolloLink.t = "setContext" 11 | 12 | @module("@apollo/client/link/context") 13 | external setContextAsync: ( 14 | (~operation: GraphQLRequest.t, ~prevContext: Js.Json.t) => Js.Promise.t 15 | ) => ApolloLink.t = "setContext" 16 | 17 | type async = (~operation: GraphQLRequest.t, ~prevContext: Js.Json.t) => Js.Promise.t 18 | } 19 | 20 | let setContext = Js_.setContext 21 | 22 | let setContextAsync: ( 23 | (~operation: GraphQLRequest.t, ~prevContext: Js.Json.t) => Js.Promise.t 24 | ) => ApolloLink.t = fn => Js_.setContextAsync(fn) 25 | 26 | // rescript-specific 27 | module ContextLink = { 28 | let make = setContext 29 | let makeAsync = setContextAsync 30 | } 31 | -------------------------------------------------------------------------------- /EXAMPLES/src/clientUsage/AsyncAwait.res: -------------------------------------------------------------------------------- 1 | module ApolloError = ApolloClient.Types.ApolloError 2 | 3 | module DuplicateTodoMutation = %graphql(` 4 | mutation AddTodo($text: String!) { 5 | todo: addTodoSimple(text: $text) { 6 | id 7 | text 8 | } 9 | } 10 | `) 11 | 12 | module TodosQuery = %graphql(` 13 | query TodosQuery { 14 | todos: allTodos { 15 | id 16 | text 17 | completed 18 | } 19 | } 20 | `) 21 | 22 | let client = Apollo.client 23 | 24 | let func = async () => { 25 | let result = await client.query(~query=module(TodosQuery), ()) 26 | 27 | let firstTodo = switch result { 28 | | Ok({data: {todos}}) => 29 | switch todos->Belt.Array.get(0) { 30 | | Some(firstTodo) => Ok(firstTodo) 31 | | None => Error(ApolloError.make(~errorMessage="No To-Dos!", ())) 32 | } 33 | | Error(_) as error => error 34 | } 35 | 36 | let result = await ( 37 | switch firstTodo { 38 | | Ok(firstTodo) => 39 | client.mutate(~mutation=module(DuplicateTodoMutation), {text: firstTodo.text}) 40 | | Error(_) as error => Promise.resolve(error) 41 | } 42 | ) 43 | 44 | switch result { 45 | | Ok(_) => Js.log("Duplicated first todo!") 46 | | Error(apolloError) => Js.log2("Something went wrong: ", apolloError.message) 47 | } 48 | } 49 | func()->ignore 50 | -------------------------------------------------------------------------------- /EXAMPLES/src/clientUsage/PromiseChaining.res: -------------------------------------------------------------------------------- 1 | module ApolloError = ApolloClient.Types.ApolloError 2 | 3 | module DuplicateTodoMutation = %graphql(` 4 | mutation AddTodo($text: String!) { 5 | todo: addTodoSimple(text: $text) { 6 | id 7 | text 8 | } 9 | } 10 | `) 11 | 12 | module TodosQuery = %graphql(` 13 | query TodosQuery { 14 | todos: allTodos { 15 | id 16 | text 17 | completed 18 | } 19 | } 20 | `) 21 | 22 | let client = Apollo.client 23 | 24 | client.query(~query=module(TodosQuery), ()) 25 | ->Promise.thenResolve(result => 26 | switch result { 27 | | Ok({data: {todos}}) => 28 | switch todos->Belt.Array.get(0) { 29 | | Some(firstTodo) => Ok(firstTodo) 30 | | None => Error(ApolloError.make(~errorMessage="No To-Dos!", ())) 31 | } 32 | | Error(_) as error => error 33 | } 34 | ) 35 | ->Promise.then(result => 36 | switch result { 37 | | Ok(firstTodo) => client.mutate(~mutation=module(DuplicateTodoMutation), {text: firstTodo.text}) 38 | | Error(_) as error => Promise.resolve(error) 39 | } 40 | ) 41 | ->Promise.then(result => 42 | Promise.resolve( 43 | switch result { 44 | | Ok(_) => Js.log("Duplicated first todo!") 45 | | Error(apolloError) => Js.log2("Something went wrong: ", apolloError.message) 46 | }, 47 | ) 48 | ) 49 | ->ignore 50 | -------------------------------------------------------------------------------- /EXAMPLES/src/hooksUsage/Query_Lazy.res: -------------------------------------------------------------------------------- 1 | module TodosQuery = %graphql(` 2 | query TodosQuery { 3 | todos: allTodos { 4 | id 5 | text 6 | completed 7 | } 8 | } 9 | `) 10 | 11 | @react.component 12 | let make = () => { 13 | let (executeQuery, queryResult) = TodosQuery.useLazy() 14 |
15 | {switch queryResult { 16 | | Unexecuted(_) => 17 | <> 18 | {"Waiting to be executed... "->React.string} 19 | 22 | 23 | | Executed({loading: true, data: None}) =>

{"Loading"->React.string}

24 | | Executed({loading, data: Some({todos}), error}) => 25 | <> 26 | 27 | {loading ?

{"Refreshing..."->React.string}

: React.null} 28 | {switch error { 29 | | Some(_) =>

{"Something went wrong, data may be incomplete"->React.string}

30 | | None => React.null 31 | }} 32 |
33 |

34 | {React.string("There are " ++ (todos->Belt.Array.length->string_of_int ++ " To-Dos"))} 35 |

36 | 37 | | Executed({loading: false, data: None}) =>

{"Error loading data"->React.string}

38 | }} 39 |
40 | } 41 | -------------------------------------------------------------------------------- /src/@apollo/client/link/retry/ApolloClient__Link_Retry_RetryFunction.res: -------------------------------------------------------------------------------- 1 | module Operation = ApolloClient__Link_Core.Types.Operation 2 | 3 | module RetryFunction = { 4 | module Js_ = { 5 | // export interface RetryFunction { 6 | // (count: number, operation: Operation, error: any): boolean | Promise; 7 | // } 8 | type t = (. int, Operation.Js_.t, option) => Js.Promise.t 9 | } 10 | 11 | type t = (~count: int, ~operation: Operation.t, ~error: option) => Js.Promise.t 12 | 13 | let toJs: (. t) => Js_.t = (. t) => 14 | (. count, operation, error) => t(~count, ~operation=operation->Operation.fromJs, ~error) 15 | } 16 | 17 | module RetryFunctionOptions = { 18 | module Js_ = { 19 | // export interface RetryFunctionOptions { 20 | // max?: number; 21 | // retryIf?: (error: any, operation: Operation) => boolean | Promise; 22 | // } 23 | type t = { 24 | max?: int, 25 | retryIf: (option, Operation.Js_.t) => Js.Promise.t, 26 | } 27 | } 28 | 29 | type t = { 30 | max?: int, 31 | retryIf: (~error: option, ~operation: Operation.t) => Js.Promise.t, 32 | } 33 | 34 | let toJs: t => Js_.t = t => { 35 | max: ?t.max, 36 | retryIf: (error, operation) => t.retryIf(~error, ~operation=operation->Operation.fromJs), 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rescript-apollo-client", 3 | "description": "ReScript bindings for the Apollo Client ecosystem", 4 | "version": "5.0.0", 5 | "keywords": [ 6 | "Apollo", 7 | "BuckleScript", 8 | "GraphQL", 9 | "ReScript" 10 | ], 11 | "license": "MIT", 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/jeddeloh/rescript-apollo-client" 15 | }, 16 | "scripts": { 17 | "build": "rescript build -with-deps", 18 | "clean": "rescript clean", 19 | "format:ci": "rescript format -check -all", 20 | "start": "rescript build -with-deps -w", 21 | "test": "jest" 22 | }, 23 | "devDependencies": { 24 | "@apollo/client": "^3.13.8", 25 | "@reasonml-community/graphql-ppx": "1.2.4-1345e061.0", 26 | "@rescript/react": "~0.11.0", 27 | "graphql": "^15.0.0", 28 | "graphql-ws": "^5.5.5", 29 | "jest": "26.5.3", 30 | "react": "^18.3.1", 31 | "react-dom": "^18.3.1", 32 | "rescript": "~10.1.2" 33 | }, 34 | "peerDependencies": { 35 | "@apollo/client": "^3.13.8", 36 | "@reasonml-community/graphql-ppx": "^1.0.0", 37 | "@rescript/react": "~0.10.0 || ~0.11.0 || ~0.12.0", 38 | "rescript": "^10.0.0 || ^11.0.0" 39 | }, 40 | "peerDependenciesMeta": { 41 | "rescript": { 42 | "optional": true 43 | } 44 | }, 45 | "workspaces": [ 46 | "EXAMPLES", 47 | "./" 48 | ] 49 | } 50 | -------------------------------------------------------------------------------- /EXAMPLES/src/fragmentsUsage/Query_Fragments.res: -------------------------------------------------------------------------------- 1 | // The TodosQuery below is going to look for a module of the same name to define the fragment 2 | module TodoItem = Fragments.TodoItem 3 | 4 | module TodosQuery = %graphql(` 5 | query TodosQuery { 6 | todos: allTodos { 7 | # This references the TodoItem fragment definition module above! 8 | ...TodoItem 9 | } 10 | } 11 | `) 12 | 13 | // It's easy to share types when using Fragments 14 | module TodoCount = { 15 | @react.component 16 | let make = (~todos: array) => 17 |

{React.string("There are " ++ (todos->Belt.Array.length->string_of_int ++ " To-Dos"))}

18 | } 19 | 20 | @react.component 21 | let make = () => { 22 | let queryResult = TodosQuery.use() 23 | 24 |
25 | {switch queryResult { 26 | | {loading: true, data: None} =>

{"Loading"->React.string}

27 | | {loading, data: Some({todos}), error} => 28 | <> 29 | 30 | {loading ?

{"Refreshing..."->React.string}

: React.null} 31 | {switch error { 32 | | Some(_) =>

{"Something went wrong, data may be incomplete"->React.string}

33 | | None => React.null 34 | }} 35 |
36 | 37 | 38 | | {loading: false, data: None} =>

{"Error loading data"->React.string}

39 | }} 40 |
41 | } 42 | -------------------------------------------------------------------------------- /docs/assets/js/c4f5d8e4.2a22f74f.js: -------------------------------------------------------------------------------- 1 | "use strict";(self.webpackChunkdocs=self.webpackChunkdocs||[]).push([[634],{1802:(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var n=r(6540),a=r(53),o=r(4492),i=r(5489),s=r(4586),c=r(6025);const l={section:"section_rC2D",featureImage:"featureImage_yA8i",hero:"hero_syme",heroInner:"heroInner_VWeJ",heroProjectTagline:"heroProjectTagline_EkV5",heroLogo:"heroLogo_jM6J",jackInTheBox:"jackInTheBox_S9I6",index:"index_MEVg",indexGetStartedButton:"indexGetStartedButton_CTr_",indexGitHubButtonWrapper:"indexGitHubButtonWrapper_WSqu",indexGitHubButton:"indexGitHubButton_vvUO"};const m=function(){const e=(0,s.A)(),{siteConfig:t={}}=e;return n.createElement(o.A,{title:"Hello from "+t.title},n.createElement("header",{className:(0,a.A)("hero hero--primary white-bg",l.heroBanner)},n.createElement("div",{className:l.heroInner},n.createElement("img",{className:(0,a.A)("banner-img",l.heroLogo),src:"img/logo.png"}),n.createElement("h1",{className:l.heroProjectTagline},n.createElement("p",{className:"hero__subtitle purple-text"},t.tagline)),n.createElement("div",{className:l.index},n.createElement(i.A,{className:l.indexGetStartedButton,to:(0,c.A)("docs/")},"Get Started"),n.createElement("span",{className:l.indexGitHubButtonWrapper},n.createElement("iframe",{className:l.indexGitHubButton,src:"https://ghbtns.com/github-btn.html?user=reasonml-community&repo=rescript-apollo-client&type=star&count=true&size=large",width:160,height:30,title:"GitHub Stars"}))))))}}}]); -------------------------------------------------------------------------------- /src/graphql/error/ApolloClient__Graphql_Error_GraphQLError.res: -------------------------------------------------------------------------------- 1 | module Ast = ApolloClient__Graphql_Language_Ast 2 | module Location = ApolloClient__Graphql_Location 3 | module Source = ApolloClient__Graphql_Language_Source.Source 4 | 5 | // export class GraphQLError extends Error { 6 | // constructor( 7 | // message: string, 8 | // nodes?: Maybe | ASTNode>, 9 | // source?: Maybe, 10 | // positions?: Maybe>, 11 | // path?: Maybe>, 12 | // originalError?: Maybe, 13 | // extensions?: Maybe<{ [key: string]: any }>, 14 | // ); 15 | // message: string; 16 | // readonly locations: ReadonlyArray | undefined; 17 | // readonly path: ReadonlyArray | undefined; 18 | // readonly nodes: ReadonlyArray | undefined; 19 | // readonly source: Source | undefined; 20 | // readonly positions: ReadonlyArray | undefined; 21 | // readonly originalError: Maybe; 22 | // readonly extensions: { [key: string]: any } | undefined; 23 | // } 24 | type stringOrNumber 25 | 26 | type t = { 27 | message: string, 28 | locations: option>, 29 | path: option>, // TODO: use union for string | number 30 | nodes: option>, 31 | source: option, 32 | position: option>, 33 | originalError: Js.nullable, 34 | extensions: option>, 35 | } 36 | -------------------------------------------------------------------------------- /EXAMPLES/src/Apollo.res: -------------------------------------------------------------------------------- 1 | let graphqlEndpoint = "localhost:4000/graphql" 2 | 3 | let headers = {"high": "five"} 4 | 5 | let httpLink = ApolloClient.Link.HttpLink.make( 6 | ~uri=_ => "http://" ++ graphqlEndpoint, 7 | ~headers=Obj.magic(headers), 8 | (), 9 | ) 10 | 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 | 17 | let wsLink = { 18 | open ApolloClient.Link.WebSocketLink 19 | make({ 20 | url: "ws://" ++ graphqlEndpoint, 21 | connectionParams: ConnectionParams(Obj.magic({"headers": headers})), 22 | shouldRetry: true, 23 | }) 24 | } 25 | 26 | let terminatingLink = ApolloClient.Link.split(~test=({query}) => { 27 | let definition = ApolloClient.Utilities.getOperationDefinition(query) 28 | switch definition { 29 | | Some({kind, operation}) => kind === "OperationDefinition" && operation === "subscription" 30 | | None => false 31 | } 32 | }, ~whenTrue=wsLink, ~whenFalse=httpLink) 33 | 34 | let client = { 35 | open ApolloClient 36 | make( 37 | ~cache=Cache.InMemoryCache.make(), 38 | ~connectToDevTools=true, 39 | ~defaultOptions=DefaultOptions.make( 40 | ~mutate=DefaultMutateOptions.make(~awaitRefetchQueries=true, ()), 41 | (), 42 | ), 43 | ~link=terminatingLink, 44 | (), 45 | ) 46 | } 47 | 48 | client.onClearStore(~cb=async () => { 49 | Js.log("store cleared") 50 | }) 51 | 52 | client.onResetStore(~cb=async () => { 53 | Js.log("store reset") 54 | }) 55 | 56 | let _ = client.clearStore() 57 | let _ = client.resetStore() 58 | -------------------------------------------------------------------------------- /docs/sitemap.xml: -------------------------------------------------------------------------------- 1 | https://jeddeloh.github.io/rescript-apollo-client/docs/weekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/changelogweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/client-configurationweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/contributingweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/gotchasweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/installationweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/mutationsweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/queriesweekly0.5https://jeddeloh.github.io/rescript-apollo-client/docs/subscriptionsweekly0.5https://jeddeloh.github.io/rescript-apollo-client/weekly0.5 -------------------------------------------------------------------------------- /documentationWebsite/docs/installation.md: -------------------------------------------------------------------------------- 1 | --- 2 | id: installation 3 | title: Installation 4 | sidebar_label: Installation 5 | --- 6 | 7 | ### 1. `graphql-ppx` 8 | 9 | We rely on Graphql-ppx for typesafe GraphQL operations and fragments in ReasonML. [Go to the official documentation](https://beta.graphql-ppx.com) for installation instructions. 10 | 11 | You should now have a `graphql_schema.json` in your project somewhere. Make sure it's always up-to-date! 12 | 13 | ### 2. Apollo Client 14 | 15 | ```sh 16 | npm install rescript-apollo-client @apollo/client 17 | ``` 18 | 19 | ### 3. Apollo-Specific `graphql-ppx` Configuration 20 | 21 | Add the following under `bs-dependencies` and `graphql`, in your `bsconfig.json` 22 | 23 | ```diff 24 | { 25 | "graphql": { 26 | + "apolloMode": true, 27 | + "extendMutation": "ApolloClient.GraphQL_PPX.ExtendMutation", 28 | + "extendQuery": "ApolloClient.GraphQL_PPX.ExtendQuery", 29 | + "extendSubscription": "ApolloClient.GraphQL_PPX.ExtendSubscription", 30 | + "templateTagReturnType": "ApolloClient.GraphQL_PPX.templateTagReturnType", 31 | + "templateTagImport": "gql", 32 | + "templateTagLocation": "@apollo/client" 33 | }, 34 | "ppx-flags": ["@reasonml-community/graphql-ppx/ppx"], 35 | "bs-dependencies: [ 36 | "@reasonml-community/graphql-ppx" 37 | + "rescript-apollo-client" 38 | ] 39 | } 40 | ``` 41 | 42 | - `"apolloMode"` automaticaly sprinkles `__typename` throughout our operation and fragment definitions 43 | - `"templateTag*"` is how we tell `graphql-ppx` to wrap every operation with `gql` 44 | - `"extend*"` allows `rescript-apollo-client` to automatically decorate the generated modules with Apollo-specific things like the correct hook for that operation! 45 | -------------------------------------------------------------------------------- /docs/assets/js/main.8b8ea7e0.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /* 2 | object-assign 3 | (c) Sindre Sorhus 4 | @license MIT 5 | */ 6 | 7 | /* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress 8 | * @license MIT */ 9 | 10 | /** 11 | * @license React 12 | * use-sync-external-store-shim.production.js 13 | * 14 | * Copyright (c) Meta Platforms, Inc. and affiliates. 15 | * 16 | * This source code is licensed under the MIT license found in the 17 | * LICENSE file in the root directory of this source tree. 18 | */ 19 | 20 | /** 21 | * Prism: Lightweight, robust, elegant syntax highlighting 22 | * 23 | * @license MIT 24 | * @author Lea Verou 25 | * @namespace 26 | * @public 27 | */ 28 | 29 | /** @license React v0.19.1 30 | * scheduler.production.min.js 31 | * 32 | * Copyright (c) Facebook, Inc. and its affiliates. 33 | * 34 | * This source code is licensed under the MIT license found in the 35 | * LICENSE file in the root directory of this source tree. 36 | */ 37 | 38 | /** @license React v16.13.1 39 | * react-is.production.min.js 40 | * 41 | * Copyright (c) Facebook, Inc. and its affiliates. 42 | * 43 | * This source code is licensed under the MIT license found in the 44 | * LICENSE file in the root directory of this source tree. 45 | */ 46 | 47 | /** @license React v16.14.0 48 | * react-dom.production.min.js 49 | * 50 | * Copyright (c) Facebook, Inc. and its affiliates. 51 | * 52 | * This source code is licensed under the MIT license found in the 53 | * LICENSE file in the root directory of this source tree. 54 | */ 55 | 56 | /** @license React v16.14.0 57 | * react.production.min.js 58 | * 59 | * Copyright (c) Facebook, Inc. and its affiliates. 60 | * 61 | * This source code is licensed under the MIT license found in the 62 | * LICENSE file in the root directory of this source tree. 63 | */ 64 | -------------------------------------------------------------------------------- /EXAMPLES/src/hooksUsage/Query_Typical.res: -------------------------------------------------------------------------------- 1 | module TodosQuery = %graphql(` 2 | query TodosQuery { 3 | todos: allTodos { 4 | id 5 | text 6 | completed 7 | } 8 | } 9 | `) 10 | 11 | @react.component 12 | let make = () => { 13 | let queryResult = TodosQuery.use() 14 | 15 |
16 | {switch queryResult { 17 | | {loading: true, data: None} =>

{"Loading"->React.string}

18 | | {loading, data: Some({todos}), error, fetchMore} => 19 |
20 | 21 | {loading ?

{"Refreshing..."->React.string}

: React.null} 22 | {switch error { 23 | | Some(_) =>

{"Something went wrong, data may be incomplete"->React.string}

24 | | None => React.null 25 | }} 26 |
27 |

28 | {React.string("There are " ++ (todos->Belt.Array.length->string_of_int ++ " To-Dos"))} 29 |

30 |

31 | 51 |

52 |
53 | | {loading: false, data: None} =>

{"Error loading data"->React.string}

54 | }} 55 |
56 | } 57 | -------------------------------------------------------------------------------- /src/@apollo/client/testing/react/ApolloClient__Testing_React_MockedProvider.res: -------------------------------------------------------------------------------- 1 | module InMemoryCache = ApolloClient__Cache_InMemory_InMemoryCache 2 | module ApolloClient = ApolloClient__Core_ApolloClient 3 | module ApolloProvider = ApolloClient__React_Context_ApolloProvider 4 | module Core = ApolloClient__Testing_Core 5 | module Types = ApolloClient__Testing_Types 6 | 7 | // export interface MockedProviderProps { 8 | // mocks?: ReadonlyArray; 9 | // addTypename?: boolean; 10 | // defaultOptions?: DefaultOptions; 11 | // cache?: ApolloCache; 12 | // resolvers?: Resolvers; 13 | // childProps?: object; 14 | // children?: any; 15 | // link?: ApolloLink; 16 | // } 17 | 18 | /* Then making an ApolloClient in Rescript, additional wrapper methods (e.g. `rescript_query`) 19 | * are created for the underlying javascript methods. So for the client to be set up correctly, 20 | * we need to do so by calling the rescript method. 21 | */ 22 | @react.component 23 | let make = ( 24 | ~addTypename=true, 25 | ~cache=?, 26 | ~childProps=?, 27 | ~children, 28 | ~defaultOptions=?, 29 | ~link=?, 30 | ~mocks: array>, 31 | ~resolvers=?, 32 | ) => { 33 | let client = React.useRef( 34 | ApolloClient.make( 35 | ~cache=cache->Belt.Option.getWithDefault(InMemoryCache.make(~addTypename, ())), 36 | ~defaultOptions?, 37 | ~link=link->Belt.Option.getWithDefault(Core.mockLink(~mocks, ~addTypename)), 38 | ~resolvers?, 39 | (), 40 | ), 41 | ) 42 | 43 | React.useEffect0(() => { 44 | Some(client.current.stop) 45 | }) 46 | 47 | 48 | {React.cloneElement( 49 | React.Children.only(children), 50 | childProps->Belt.Option.mapWithDefault(Js.Obj.empty(), props => 51 | Js.Obj.assign(props, Js.Obj.empty()) 52 | ), 53 | )} 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/@apollo/client/utilities/policies/ApolloClient__Utilities_Policies_Pagination.res: -------------------------------------------------------------------------------- 1 | module FieldPolicy = ApolloClient__Cache_InMemory_Policies_FieldPolicy.FieldPolicy 2 | module KeyArgs = ApolloClient__Cache_InMemory_Policies_FieldPolicy.FieldPolicy_KeyArgs 3 | 4 | // declare type TInternalRelay = Readonly<{ 5 | // edges: Array<{ 6 | // cursor: string; 7 | // node: TNode; 8 | // }>; 9 | // pageInfo: Readonly<{ 10 | // hasPreviousPage: boolean; 11 | // hasNextPage: boolean; 12 | // startCursor: string; 13 | // endCursor: string; 14 | // }>; 15 | // }>; 16 | 17 | module Js_ = { 18 | // export declare function concatPagination(keyArgs?: KeyArgs): FieldPolicy; 19 | @module("@apollo/client/utilities") @val 20 | external concatPagination: (. option) => FieldPolicy.Js_.t<'existing> = 21 | "concatPagination" 22 | 23 | // export declare function offsetLimitPagination(keyArgs?: KeyArgs): FieldPolicy; 24 | @module("@apollo/client/utilities") @val 25 | external offsetLimitPagination: (. option) => FieldPolicy.Js_.t<'existing> = 26 | "offsetLimitPagination" 27 | 28 | // export declare function relayStylePagination(keyArgs?: KeyArgs): FieldPolicy>; 29 | @module("@apollo/client/utilities") @val 30 | external relayStylePagination: (. option) => FieldPolicy.Js_.t<'existing> = 31 | "relayStylePagination" 32 | } 33 | 34 | let concatPagination: KeyArgs.t => FieldPolicy.Js_.t<'existing> = keyArgs => 35 | Js_.concatPagination(. Some(KeyArgs.toJs(. keyArgs))) 36 | 37 | let offsetLimitPagination: KeyArgs.t => FieldPolicy.Js_.t<'existing> = keyArgs => 38 | Js_.offsetLimitPagination(. Some(KeyArgs.toJs(. keyArgs))) 39 | 40 | let relayStylePagination: KeyArgs.t => FieldPolicy.Js_.t<'existing> = keyArgs => 41 | Js_.relayStylePagination(. Some(KeyArgs.toJs(. keyArgs))) 42 | -------------------------------------------------------------------------------- /EXAMPLES/src/hooksUsage/Query_SubscribeToMore.res: -------------------------------------------------------------------------------- 1 | module QueryResult = ApolloClient.Types.QueryResult 2 | 3 | module TodosQuery = %graphql(` 4 | query TodosQuery { 5 | todos: allTodos { 6 | id 7 | completed 8 | text 9 | } 10 | } 11 | `) 12 | 13 | module SorryItsNotASubscriptionForTodos = %graphql(` 14 | subscription SorryItsNotASubscriptionForTodos { 15 | siteStatisticsUpdated { 16 | currentVisitorsOnline 17 | } 18 | } 19 | `) 20 | 21 | @react.component 22 | let make = () => { 23 | let queryResult = TodosQuery.use() 24 | 25 | @ocaml.doc(" 26 | * Sorry, this example is nonsensical given the current schema, but I'm gonna proceed anyway 27 | ") 28 | React.useEffect0(() => { 29 | let _unsubscribe = queryResult.subscribeToMore( 30 | ~subscription=module(SorryItsNotASubscriptionForTodos), 31 | ~updateQuery=(previous, {subscriptionData: {data: {siteStatisticsUpdated}}}) => { 32 | let count = 33 | siteStatisticsUpdated 34 | ->Belt.Option.map(stats => stats.currentVisitorsOnline) 35 | ->Belt.Option.getWithDefault(0) 36 | ->string_of_int 37 | 38 | { 39 | todos: Belt.Array.concat( 40 | previous.todos, 41 | [ 42 | { 43 | __typename: "TodoItem", 44 | id: "subscribeToMoreTodo", 45 | completed: None, 46 | text: "Hello, " ++ (count ++ " vistors online"), 47 | }, 48 | ], 49 | ), 50 | } 51 | }, 52 | (), 53 | ) 54 | None 55 | }) 56 | 57 | <> 58 |

{"[ Not functional, but the examples are still valid ]"->React.string}

59 | {switch queryResult { 60 | | {data: Some({todos})} => 61 |

62 | {React.string("There are " ++ (todos->Belt.Array.length->string_of_int ++ " To-Dos"))} 63 |

64 | | _ignoredForExample => React.null 65 | }} 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/ApolloClient__Utils.res: -------------------------------------------------------------------------------- 1 | module ApolloError = ApolloClient__Errors_ApolloError 2 | module Graphql = ApolloClient__Graphql 3 | module Types = ApolloClient__Types 4 | 5 | @new external makeError: string => Js.Exn.t = "Error" 6 | 7 | let ensureError = ApolloError.ensureError 8 | 9 | external asJson: 'any => Js.Json.t = "%identity" 10 | 11 | let safeParse: (. 'jsData => 'data) => Types.safeParse<'data, 'jsData> = (. parse) => 12 | (. jsData) => 13 | switch parse(jsData) { 14 | | data => Ok(data) 15 | | exception Js.Exn.Error(error) => Error({value: jsData->asJson, error}) 16 | } 17 | 18 | let safeParseAndLiftToCommonResultProps: ( 19 | ~jsData: option<'jsData>, 20 | ~graphQLErrors: array=?, 21 | ~apolloError: ApolloError.t=?, 22 | Types.safeParse<'data, 'jsData>, 23 | ) => (option<'data>, option) = ( 24 | ~jsData, 25 | ~graphQLErrors=?, 26 | ~apolloError=?, 27 | safeParse, 28 | ) => { 29 | let existingError = switch (apolloError, graphQLErrors) { 30 | | (Some(_), _) => apolloError 31 | | (_, Some(graphQLErrors)) => Some(ApolloError.make(~graphQLErrors, ())) 32 | | (None, None) => None 33 | } 34 | 35 | switch Belt.Option.mapU(jsData, safeParse) { 36 | | Some(Error(parseError)) => 37 | // Be careful we do not overwrite an existing error with a ParseError 38 | existingError->Belt.Option.isSome 39 | ? (None, existingError) 40 | : (None, Some(ApolloError.make(~networkError=ParseError(parseError), ~graphQLErrors?, ()))) 41 | | Some(Ok(data)) => (Some(data), existingError) 42 | | None => (None, existingError) 43 | } 44 | } 45 | 46 | let useGuaranteedMemo1 = (f, dependency) => { 47 | let value = React.useRef(f()) 48 | let previousDependency = React.useRef(dependency) 49 | 50 | if dependency !== previousDependency.current { 51 | value.current = f() 52 | previousDependency.current = dependency 53 | } 54 | 55 | value.current 56 | } 57 | 58 | external identity: 'a => 'a = "%identity" 59 | -------------------------------------------------------------------------------- /documentationWebsite/docusaurus.config.js: -------------------------------------------------------------------------------- 1 | const baseUrl = 2 | process.env.DOCS_ENV === "development" ? "/" : "/rescript-apollo-client/"; 3 | 4 | module.exports = { 5 | title: "ReScript Apollo Client", 6 | tagline: "Rescript bindings for the Apollo Client ecosystem", 7 | url: "https://jeddeloh.github.io", 8 | baseUrl, 9 | onBrokenLinks: "throw", 10 | favicon: "img/favicon.ico", 11 | organizationName: "jeddeloh", // Usually your GitHub org/user name. 12 | projectName: "rescript-apollo-client", // Usually your repo name. 13 | themeConfig: { 14 | colorMode: { 15 | // Hides the switch in the navbar 16 | // Useful if you want to support a single color mode 17 | disableSwitch: true, 18 | }, 19 | navbar: { 20 | title: "ReScript Apollo Client", 21 | logo: { 22 | alt: "ReScript Apollo Client Logo", 23 | src: "img/small_logo.png", 24 | }, 25 | items: [ 26 | { 27 | label: "Docs", 28 | to: "docs/", 29 | activeBasePath: "docs", 30 | position: "left", 31 | }, 32 | { 33 | label: "Changelog", 34 | to: "https://github.com/jeddeloh/rescript-apollo-client/releases/", 35 | position: "left", 36 | }, 37 | { label: "Contributing", to: "docs/contributing", position: "right" }, 38 | { 39 | label: "GitHub", 40 | href: "https://github.com/jeddeloh/rescript-apollo-client", 41 | position: "right", 42 | }, 43 | ], 44 | }, 45 | footer: { 46 | style: "dark", 47 | copyright: `Built with Docusaurus.`, 48 | }, 49 | }, 50 | presets: [ 51 | [ 52 | "@docusaurus/preset-classic", 53 | { 54 | docs: { 55 | sidebarPath: require.resolve("./sidebars.js"), 56 | // Please change this to your repo. 57 | editUrl: 58 | "https://github.com/jeddeloh/rescript-apollo-client/edit/master/documentationWebsite", 59 | }, 60 | theme: { 61 | customCss: require.resolve("./src/css/custom.css"), 62 | }, 63 | }, 64 | ], 65 | ], 66 | }; 67 | -------------------------------------------------------------------------------- /documentationWebsite/src/pages/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import clsx from "clsx"; 3 | import Layout from "@theme/Layout"; 4 | import Link from "@docusaurus/Link"; 5 | import useDocusaurusContext from "@docusaurus/useDocusaurusContext"; 6 | import useBaseUrl from "@docusaurus/useBaseUrl"; 7 | import styles from "./styles.module.css"; 8 | 9 | function Feature({ imageUrl, title, description }) { 10 | const imgUrl = useBaseUrl(imageUrl); 11 | return ( 12 |
13 | {imgUrl && ( 14 |
15 | {title} 16 |
17 | )} 18 |

{title}

19 |

{description}

20 |
21 | ); 22 | } 23 | 24 | function Home() { 25 | const context = useDocusaurusContext(); 26 | const { siteConfig = {} } = context; 27 | return ( 28 | 29 |
32 |
33 | 37 |

38 |

{siteConfig.tagline}

39 |

40 |
41 | 45 | Get Started 46 | 47 | 48 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/@apollo/client/core/ApolloClient__Core_Types.res: -------------------------------------------------------------------------------- 1 | module ApolloError = ApolloClient__Errors_ApolloError 2 | module Graphql = ApolloClient__Graphql 3 | module FetchResult = ApolloClient__Link_Core_Types.FetchResult 4 | module NetworkStatus = ApolloClient__Core_NetworkStatus.NetworkStatus 5 | module Resolver = ApolloClient__Core_LocalState.Resolver 6 | module Types = ApolloClient__Types 7 | module Utils = ApolloClient__Utils 8 | 9 | module OperationVariables = { 10 | module Js_ = { 11 | // export declare type OperationVariables = Record; 12 | type t = Js.Json.t 13 | } 14 | type t = Js_.t 15 | } 16 | 17 | module PureQueryOptions = { 18 | module Js_ = { 19 | // export declare type PureQueryOptions = { 20 | // query: DocumentNode; 21 | // variables?: { 22 | // [key: string]: any; 23 | // }; 24 | // context?: any; 25 | // }; 26 | type t<'jsVariables> = { 27 | query: Graphql.documentNode, 28 | // We don't allow optional variables because it's not typesafe 29 | variables: 'jsVariables, 30 | context?: Js.Json.t, 31 | } 32 | } 33 | 34 | type t<'jsVariables> = { 35 | query: Graphql.documentNode, 36 | variables: 'jsVariables, 37 | context?: Js.Json.t, 38 | } 39 | 40 | let toJs: t<'jsVariables> => Js_.t<'jsVariables> = t => { 41 | query: t.query, 42 | variables: t.variables, 43 | context: ?t.context, 44 | } 45 | } 46 | 47 | module ApolloQueryResult = { 48 | module Js_ = { 49 | // export declare type ApolloQueryResult = { 50 | // data?: T; 51 | // errors?: ReadonlyArray; 52 | // loading: boolean; 53 | // networkStatus: NetworkStatus; 54 | // }; 55 | type t<'jsData> = { 56 | data: option<'jsData>, 57 | errors: option>, 58 | loading: bool, 59 | networkStatus: int, 60 | } 61 | } 62 | 63 | type t<'data> = { 64 | data: option<'data>, 65 | @ocaml.doc(" 66 | * Intentionally elevated from array(Graphql.Error.GraphQLError.t) to ApolloError. 67 | * This allows us to incorporate network and parse failures into a single result. 68 | ") 69 | error: option, 70 | loading: bool, 71 | networkStatus: NetworkStatus.t, 72 | } 73 | 74 | let fromJs: (Js_.t<'jsData>, ~safeParse: Types.safeParse<'data, 'jsData>) => t<'data> = ( 75 | js, 76 | ~safeParse, 77 | ) => { 78 | let (data, error) = Utils.safeParseAndLiftToCommonResultProps( 79 | ~jsData=js.data, 80 | ~graphQLErrors=?js.errors, 81 | safeParse, 82 | ) 83 | 84 | { 85 | data, 86 | error, 87 | loading: js.loading, 88 | networkStatus: js.networkStatus->NetworkStatus.fromJs, 89 | } 90 | } 91 | 92 | let fromError: ApolloError.t => t<'data> = error => { 93 | data: None, 94 | error: Some(error), 95 | loading: false, 96 | networkStatus: Error, 97 | } 98 | 99 | type t__ok<'data> = { 100 | data: 'data, 101 | error: option, 102 | loading: bool, 103 | networkStatus: NetworkStatus.t, 104 | } 105 | 106 | let toResult: t<'data> => Belt.Result.t, ApolloError.t> = apolloQueryResult => 107 | switch apolloQueryResult { 108 | | {data: Some(data)} => 109 | Ok({ 110 | data, 111 | error: apolloQueryResult.error, 112 | loading: apolloQueryResult.loading, 113 | networkStatus: apolloQueryResult.networkStatus, 114 | }) 115 | | {error: Some(error)} => Error(error) 116 | | {data: None, error: None} => 117 | Error( 118 | ApolloError.make( 119 | ~errorMessage="No data and no error on ApolloQueryResult.t. Shouldn't this be impossible?", 120 | (), 121 | ), 122 | ) 123 | } 124 | } 125 | 126 | module MutationQueryReducer = { 127 | module Js_ = { 128 | // export declare type MutationQueryReducer = (previousResult: Record, options: { 129 | // mutationResult: FetchResult; 130 | // queryName: string | undefined; 131 | // queryVariables: Record; 132 | // }) => Record; 133 | type options<'jsData> = { 134 | mutationResult: FetchResult.Js_.t<'jsData>, 135 | queryName: option, 136 | queryVariables: Js.Json.t, // ACTUAL: Record 137 | } 138 | 139 | type t<'jsData> = (. Js.Json.t, options<'jsData>) => Js.Json.t 140 | } 141 | 142 | type options<'data> = { 143 | mutationResult: FetchResult.t<'data>, 144 | queryName: option, 145 | queryVariables: Js.Json.t, // ACTUAL: Record 146 | } 147 | 148 | type t<'data> = (Js.Json.t, options<'data>) => Js.Json.t 149 | 150 | let toJs: ( 151 | . t<'data>, 152 | ~safeParse: Types.safeParse<'data, 'jsData>, 153 | Js.Json.t, 154 | Js_.options<'jsData>, 155 | ) => Js.Json.t = (. t, ~safeParse, previousResult, jsOptions) => 156 | t( 157 | previousResult, 158 | { 159 | mutationResult: jsOptions.mutationResult->FetchResult.fromJs(~safeParse), 160 | queryName: jsOptions.queryName, 161 | queryVariables: jsOptions.queryVariables, 162 | }, 163 | ) 164 | } 165 | 166 | module MutationQueryReducersMap = { 167 | module Js_ = { 168 | // export declare type MutationQueryReducersMap = { 171 | // [queryName: string]: MutationQueryReducer; 172 | // }; 173 | type t<'jsData> = Js.Dict.t> 174 | } 175 | 176 | type t<'data> = Js.Dict.t> 177 | 178 | let toJs: (. t<'data>, ~safeParse: Types.safeParse<'data, 'jsData>) => Js_.t<'jsData> = (. 179 | t, 180 | ~safeParse, 181 | ) => 182 | Js.Dict.map( 183 | (. mutationQueryReducer) => 184 | (. json, options) => 185 | MutationQueryReducer.toJs(. mutationQueryReducer, ~safeParse, json, options), 186 | t, 187 | ) 188 | } 189 | 190 | module Resolvers = { 191 | module Js_ = { 192 | // export interface Resolvers { 193 | // [key: string]: { 194 | // [field: string]: Resolver; 195 | // }; 196 | // } 197 | type t = Js.Dict.t> 198 | } 199 | type t = Js_.t 200 | } 201 | --------------------------------------------------------------------------------