All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Given that Wonka has been converted to typescript, we don't rely on the Reason version. (ReScript 11 also doesn't support Reason syntax anymore). This has been replaced with the Wonka module that just binds to JavaScript. We had to depend on the GitHub version of @glennsl/rescript-fetch, but we fix that once it's released on NPM. Also note that we are not supporting uncurried mode yet, given that graphql-ppx doesn't support it yet, it's not relevant yet. But we will fix it once we are able to!
This release adds support for several major version upgrades of dependencies, including:
- Support for
urql@2.0.0. - Support for
@rescript/react.reason-reactis no longer supported moving forward. - Support for
bs-platform@9.0.0.
This release also includes a name change. This package will now be published under the @urql scope as @urql/rescript. To install it, run:
yarn add @urql/rescriptreason-urqlis now available as@urql/rescript. PR by @parkerziegler here.@urql/rescriptis now compatible withurql@2.0.0,bs-platform@9.0.0, and@rescript/react. You must upgrade to@rescript/reactfromreason-reactto use v4.0.0. PR by @parkerziegler here.- The
pollIntervalAPI was removed from all hooks and Client methods, in accordance with the upstream deprecation of this API inurql@2.0.0. PR by @parkerziegler here. More information on this deprecation can be found in theurqlCHANGELOG.
https://github.com/FormidableLabs/reason-urql/compare/v3.4.0...v4.0.0
This release adds bindings for two additional ecosystem exchanges:
- Bindings for
@urql/exchange-persisted-fetchand@urql/exchange-refocuswere added. Consumers ofreason-urqlwill need to install@urql/exchange-persisted-fetchto callClient.Exchanges.persistedFetchExchangeand@urql/exchange-refocusto callClient.Exchanges.refocusExchange. PR by @parkerziegler here.
https://github.com/FormidableLabs/reason-urql/compare/v3.3.0...v3.4.0
This release adds bindings for two additional ecosystem exchanges:
- Bindings for
@urql/exchange-retryand@urql/exchange-request-policywere added. Consumers ofreason-urqlwill need to install@urql/exchange-retryto callClient.Exchanges.retryExchangeand@urql/exchange-request-policyto callClient.Exchanges.requestPolicyExchange. PRs by @parkerziegler here and here.
https://github.com/FormidableLabs/reason-urql/compare/v3.2.0...v3.3.0
This release adds a thin binding for @urql/exchange-multipart-fetch.
- A thin binding for
@urql/exchange-multipart-fetchwas added. Consumers ofreason-urqlwill need to install@urql/exchange-multipart-fetchto callClient.Exchanges.multipartFetchExchange. PR by @parkerziegler here. Fixes #169.
https://github.com/FormidableLabs/reason-urql/compare/v3.1.0...v3.2.0
This release migrates our internal syntax from Reason to ReScript. It also revises our binding of CombinedError to be compatible with ReScript, which doesn't support binding JS classes to OCaml classes as BuckleScript once did. The experience for end users should be no different.
- The codebase is now written in ReScript. PR by @parkerziegler here.
- The binding to
CombinedErroris now a record rather than an OCaml class being bound to a JS class. This change was made to both increase simplicity and to prepare for the BuckleScript to ReScript migration. PR by @parkerziegler here.
https://github.com/FormidableLabs/reason-urql/compare/v3.0.0...v3.1.0
This release migrates us to using @reasonml-community/graphql-ppx as our GraphQL PPX preprocessor of choice in lieu of @baransu/graphql_ppx_re. It also converts urql to a peerDependency of the library rather than bundling urql as a direct dependency. Finally, this release includes support for BuckleScript / ReScript > 8.0.0.
-
urql, along with its ownpeerDependencies, should be installed alongsidereason-urql, which no longer bundlesurqlas a direct dependency. See updated installation instructions in the README. PR by @parkerziegler here. -
Users should install
@reasonml-community/graphql-ppxas apeerDependencyofreason-urql. -
Users depending on
bs-platform>=8.0.0will need to specify a resolution forwonkav5 using yarn resolutions. See updated installation instructions in the README. -
Client.execute*methods underwent four major API changes:- There is no longer a
~requestlabelled argument. Instead, the GraphQL operation is passed using~queryforClient.executeQuery,~mutationforClient.executeMutation, and~subscriptionforClient.executeSubscription. This applies toClient.query,Client.mutation,Client.subscription, andClient.readQueryas well. - GraphQL operations are passed as first-class modules to
Client.execute*methods. This means you pass your entire GraphQL querymoduleas a function argument, like so:
open ReasonUrql; module GetAllDogs = [%graphql {| query getAllDogs { dogs { name breed likes } } |}]; /* Pass GetAllDogs as a first-class module to Client.executeQuery. */ Client.executeQuery(~query=(module GetAllDogs), ())
- Variables are passed as the last positional argument to
Client.execute*methods, if they are required. PR by @parkerziegler here. We interface with@reasonml-community/graphql-ppxto typecheck yourvariablesbased on the signature of your GraphQL operation. If your query, mutation, or subscription requires variables, pass them as a record in the last position, like so:
open ReasonUrql; module GetDog = [%graphql {| query getDog($key: ID!) { dog(key: $key) { name breed likes } } |}]; /* Pass GetDog as a first-class module to Client.executeQuery, with required variables as a record in the final position. */ Client.executeQuery(~query=(module GetDog), {key: "12345"})
- The
responsevariant forClient.execute*methods was renamed tooperationResponseand should be referenced from theTypesmodule rather than theClientmodule.
- There is no longer a
-
The hooks APIs underwent three major API changes:
- There is no longer a
~requestlabelled argument. Instead, the GraphQL operation is passed using~queryforuseQuery,~mutationforuseMutation, and~subscriptionforuseSubscription. - GraphQL operations are passed as first-class modules to each hook. This means you pass your entire GraphQL query
moduleas a function argument, like so:
open ReasonUrql; module GetAllDogs = [%graphql {| query getAllDogs { dogs { name breed likes } } |}]; [@react.component] let make = () => { /* Pass GetAllDogs as a first-class module to useQuery. */ let (Hooks.{response}, _) = Hooks.useQuery(~query=(module GetAllDogs), ()); /* Return the JSX for your component. */ }
- Variables are passed as the last positional argument to a hook, if they are required. PR by @amiralies here. We interface with
@reasonml-community/graphql-ppxto typecheck yourvariablesbased on the signature of your GraphQL operation. If your query, mutation, or subscription requires variables, pass them as a record in the last position, like so:
module GetDog = [%graphql {| query getDog($key: ID!) { dog(key: $key) { name breed likes } } |}]; [@react.component] let make = () => { /* Pass GetDog as a first-class module to useQuery, with required variables as a record in the final position. */ let (Hooks.{response}, _) = Hooks.useQuery(~query=(module GetDog), {key: "12345"}); /* Return the JSX for your component. */ }
- There is no longer a
- The
useDynamicMutationhook was removed.useMutationnow consolidates the former use case for this hook and brings our APIs more inline with howurqlworks.
https://github.com/FormidableLabs/reason-urql/compare/v2.1.0...v3.0.0
This release is the first release candidate for v3.0.0, which will use @reasonml-community/graphql-ppx as our PPX preprocessor for GraphQL operations. Breaking changes will be listed in the release notes for the first stable release of v3.0.0.
https://github.com/FormidableLabs/reason-urql/compare/v2.1.0...v3.0.0-rc.0
This release brings our urql dependency up to v1.10.0, at parity with the current state of urql 🙌. There are no code changes involved from the previous RC release.
https://github.com/FormidableLabs/reason-urql/compare/v2.1.0-rc.0...v2.1.0
This release fixes some important bugs identified in the v2.0.0 release.
- Properly handle
nullon thedatafield in the GraphQL response. This was a regression from v1.7.0. PR by @parkerziegler and @gaku-sei here. - Revert to using
[@bs.deriving abstract]to internally createPartial<OperationContext>objects. PR by @parkerziegler here.
https://github.com/FormidableLabs/reason-urql/compare/v2.0.0...v2.1.0-rc0
This release includes full support for BuckleScript 7 and widely reorganizes reason-urql to be more modular and easier to contribute to. Most of the public API has stayed the same, with some exceptions (documented below).
Users who upgrade to v2 should be on BuckleScript 7, as this library relies heavily on direct record to object compilation.
- All hooks and
Client.execute*methods that accepted a partial operation context argument now accept each key of theoperationContextrecord type as an optional function argument. For example, you can now write code like this:
open ReasonUrql;
/* Define query to execute. */
let subscription = Client.executeQuery(~query, ~requestPolicy=`CacheFirst, ~pollInterval=200, ());reason-urql will handle compiling each argument and passing it along to urql properly.
- Interface files (
.rei) were added for allmodules. - The
staleflag is now returned on all results returned byreason-urqlhooks, which indicates that the result returned by the hook is stale and that another request is being sent in the background. This is particularly useful with the `CacheAndNetwork request policy.
- The
responsevariant now has 5 constructors –Fetching,Data(d),PartialData(d, e),Error(e), andEmpty. You can read more about each of these here. - The
UrqlTypesmodule is now justTypes. - The
Exchangesmodule is now a sub-module of theClientmodule. OnceReasonUrqlis brought into scope it can be refrenced asClient.Exchanges. ssrExchangenow acceptsssrExchangeParamsas its first labeled argument, notssrExchangeOpts.ssrExchangeParamsis also a record type whilessrExchangeOptswas a[@bs.deriving abstract]. This brings it more in line withurql's implementation.serializedResultis now a record type rather than a[@bs.deriving abstract].- The signature of exchanges has changed to properly support uncurrying syntax.
type t =
exchangeInput =>
(. Wonka.Source.t(UrqlClientTypes.operation)) =>
Wonka.Source.t(UrqlClientTypes.operationResult);- Local binding of
graphQLErroris now a record type rather than a[@bs.deriving abstract]and has its own moduleGraphQLError.
- Component bindings for
Query,Mutation,Subscription, andSubscriptionWithHandlerwere removed. Just use the hooks APIs! Clientmethods forexecuteRequestOperation,reexecuteOperation,createRequestOperation, anddispatchOperationwere removed. These are no longer inurql's public facing API.
https://github.com/FormidableLabs/reason-urql/compare/v1.7.0...v2.0.0
This release migrates our dependency on urql to v1.5.1. It also migrates our devDependency on bs-platform (the BuckleScript compiler), to v7.2.2. While we don't expect this to affect end users still on BuckleScript v6, there may be small bugfixes and optimizations coming in the near future to support this migration.
- Add support for
Promise-based methodsqueryandmutationon the Client. This allows users to interact with Client operation results asJs.Promise.trather thanWonka.sourceT. PR by @parkerziegler here. - Add bindings for the
useClienthook. PR by @parkerziegler here.
- Migrate local
devDependencyonbs-platformto v7.2.2 and in-repo compilation target toes6. PR by @parkerziegler here. - Remove
peerDependencyonbs-fetch.
https://github.com/FormidableLabs/reason-urql/compare/v1.6.0...v1.7.0
This release migrates our dependency on urql to v1.4.0. This adds support for setting a default requestPolicy on the Client, in addition to setting up polling for your GraphQL queries using the pollInterval argument to useQuery and the Query component.
- Add option to set a default
requestPolicyon the Client. PR by @JoviDeCroock here. - Add
pollIntervalargument touseQueryhook andQuerycomponent. PR by @JoviDeCroock here.
https://github.com/FormidableLabs/reason-urql/compare/v1.5.0...v1.6.0
This release migrates our dependency on urql to v1.3.0. As such, we now have support for GraphQL extensions, custom fetch implementations, and adjustable operation contexts for queries and mutations.
- Access GraphQL extensions returned by your GraphQL API inside all hooks and componentts. PR by @parkerziegler here.
- Add support for a custom
fetchimplementation toclientOptions. Pr by @parkerziegler here. - Support an optional
contextargument toexecuteQueryandexecuteMutation, in addition to an optional initialcontextprop / argument for theQuerycomponent anduseQueryhook. PRs by @parkerziegler here and here.
- Improved documentation on the
reason-urqlAPI. PR by @parkerziegler here.
https://github.com/FormidableLabs/reason-urql/compare/v1.4.1...v1.5.0
This release fixes a small bug with requestPolicy in useQuery. We weren't properly converting the polymorphic variants passed by a user to their JS string representation, which led to improper request policies being used by the urql Client.
- Properly unwrap user-supplied
requestPolicyto the matching JS string representation. PR by @baransu here.
https://github.com/FormidableLabs/reason-urql/compare/v1.4.0...v1.4.1
This release adds support for a useDynamicMutation hook, which allows users to pass variables to the executeMutation function returned by the hook at execution time, as opposed to at render time as useMutation does.
- Add
useDyanmicMutationhook to support applying variables when callingexecuteMutation. PR by @Schmavery and @sgrove here.
- Restore CI by migrating off of GitHub Actions to Travis CI. PR by @parkerziegler here.
https://github.com/FormidableLabs/reason-urql/compare/v1.3.0...v1.4.0
This release migrates us to bs-platform@6.2.1 and ensures reason-urql is compatible for codebases using latest bs-platform.
- Documentation on using
graphql_ppx_rewithreason-urql. PR by @huy-nguyen here. - Improved Getting Started documentation. PR by @parkerziegler here.
- Fix type for
pauseargument toQuerycomponent forbs-platform@6.2.1. PR by @gugahoa here. - Migrate to
bs-platform@6.2.1in source. Fix compiler warnings. RenamepartialOperationContextFntoexecuteQuery. This is a breaking change.
https://github.com/FormidableLabs/reason-urql/compare/v1.2.0...v1.3.0
This release upgrades our urql dependency to 1.2.0 and picks up a handful of small bugfixes introduced in that release.
- The
operationContextobject now has ametaproperty on it, containing fields forsource,cacheOutcome, andnetworkLatency. These fields are likely to be deprecated in the next minor release and moved tobs-urql-devtools-exchange.
urqldependency upgraded to v1.2.0!bs-platformdependency upgraded to v5.2.1! PR by @parkerziegler here.- Some cmall changes to spurce up the example projects!
https://github.com/FormidableLabs/reason-urql/compare/v1.1.0...v1.2.0
This release adds experimental support for server-side rendering with the addition of bindings for the ssrExchange.
- Bindings for
ssrExchangeand thesuspenseoption on theClient.makefunction. PR by @parkerziegler here. - Initial docs for server side rendering support. PR by @parkerziegler here.
urqldependency upgraded to v1.1.3!
- Minor docs fix by for the
Clientmodule. PR by @robinweser here. bsconfig.jsonandpackage.jsonfiles from theexamplesdirectory are no longer published tonpm.
https://github.com/FormidableLabs/reason-urql/compare/v1.0.2...v1.1.0
This release makes a small change around the API for CombinedError. Specifically, the module type t for CombinedError now refers to the record exposed by the module rather than the Js.t / OCaml class binding urql's native CombinedError class. Better documentation for CombinedError was also added.
CombinedError.tnow references the record exposed by theCombinedErrormodule containing fields formessage,networkError,graphQLErrors, andmessage. PR by @Schmavery and @parkerziegler here.
- Capitalization / casing for the
graphQLErrorsfield onCombinedError.t. Previously this was bound asgraphqlErrors, which would always result inNonebeing returned asurqlhas nographqlErrorsfield. PR by @Schmavery here.
https://github.com/FormidableLabs/reason-urql/compare/v1.0.1...v1.0.2
This release removes bs-fetch as a dependency such that it doesn't conflict with a user's local copy of bs-fetch. Since we only use bs-fetch for type checking fetchOptions, it can safely be included as a devDependency. This release also adds a message field on the combinedError record to provide users access to the raw error string from urql.
- Dependency on
bs-fetch.bs-fetchis now adevDependencyforreason-urqland can also be installed as apeerDependencyif you want to use a different version in your app. PR by @parkerziegler and @gugahoa here.
messagefield onCombinedError.combinedError. This represents the raw stringmessagereturned by theurqlclient for your requests. PR by @Schmavery here.
https://github.com/FormidableLabs/reason-urql/compare/v1.0.0...v1.0.1
This release represents the first stable reason of reason-urql. From this point forward we'll be starting to enforce semantic versioning for all changes. Thank you so much to all of the contributors who helped us to achieve this milestone!
- A Getting Started guide to help first time users of
reason-urqlget up and running.
- The
Error(e)constructor of theresponsevariant has been moved above theData(d)constructor to better matchurql's JS API, where uses check for error responses on the GraphQL request before operating on data. - The
TypesandClient.Typesmodules were renamed toUrqlTypesandClient.ClientTypesto avoid namespace collisions with user-definedTypesmodules.
https://github.com/FormidableLabs/reason-urql/compare/v1.0.0-beta.3...v1.0.0
This release adds improved type inference around the Client's execute* methods (i.e. executeQuery, executeMutation, and executeSubscription). Responses will now be fully type checked at compile time. This release also pins the bound version of urql to 1.0.5 to address a regression that occurs when using urql > 1.2.0.
- Add proper type inference to
Client.execute*methods. This now involves passing the fullgraphql_ppxmodule to theClientsuch that it can grab theparsemethod off of it to properly infer the response. This mimics exactly how the components and hooks work. - Reorganize types to reduce redundancy and ensure unique generation of
[@bs.deriving abstract]accessors. This change is mostly internal, but it begins to isolated types used by differentmodules into submodules. For example, rather than all types living in the top-levelTypesmodule, certain types reserved for particular domains, i.e. theClient, live in a submodule i.e.Client.Types.
https://github.com/FormidableLabs/reason-urql/compare/v1.0.0-beta.2...v1.0.0-beta.3
This release adds small improvements around client.fetchOptions and the CombinedError API.
- The
FetchFnvariant of the client'sfetchOptionsargument now supports calling the function at runtime of the client rather than invoking it early in order to pass afetchOptionsobject tourql. UrqlCombinedErroris now properly bound using OCaml classes. A helper was added to convert theCombinedErrorJs.tto a record type to allow for nicer, typesafe access.
https://github.com/FormidableLabs/reason-urql/compare/v1.0.0-beta.1...v1.0.0-beta.2
This release includes support for urql hooks, including useQuery, useMutation, and useSubscription. It also includes additions to support proper type inference of GraphQL requests, such that users get compile-time guarantees that they are accessing data in a fully type-safe way.
- Bindings for
useQuery,useMutation, anduseSubscription. - Bindings for
SubscriptionWithHandler, which is to be used in cases where a customhandlerfunction is passed to theSubscriptioncomponent to accumulate subscriptions. - The top-level
urqlcontext object, which exposes aConsumerandProvider, is now exposed to the user.
- Migrated all components and examples to latest ReasonReact syntax (
"jsx: 3"). - Add proper type inference for hooks and components. This is achieved by passing the entire
graphql_ppxmodule to the hooks, which allows them to use theparsemethod to infer the return type of data from the request.
https://github.com/parkerziegler/reason-urql/compare/v1.0.0-beta...v1.0.0-beta.1
This represents the beta release of v1, which provides support for urql v1.
- Bindings for
Query,Mutation, andSubscriptioncomponents. - Bindings for
Clientwith support for exchanges. - Bindings for
Provider. - Bindings for
urql's type interfaces, utils, and helpers. - Examples for
Query,Mutation,Subscription, exposed exchanges, custom exchanges, and imperativeClientmethods. - First tests for
UrqlClient.
https://github.com/parkerziegler/reason-urql/compare/v0.1.1...v1.0.0-beta
- Additional tests for
Query,Mutation,Connect, andClient.
- The
invalidatecache operation supplied toConnectnow properly accepts a single, optional labelled argument~query: Query.urqlQuery. This will now type check properly thanks to a final positionalunitparameter in the type definition.
https://github.com/parkerziegler/reason-urql/compare/v0.1.0...v0.1.1
Welcome to v0.1.0 of reason-urql. With this release, we are moving into a stable state and will continue onwards with standard semantic versioning.
- Automated builds with Travis CI.
- Automated coverage reporting with Coveralls.
- Unit tests for
UrqlQuery,UrqlMutation,UrqlConnect,UrqlClient, andUrqlProvider. - Codified utilities for making tests more concise – see
TestUtils.re. - Zero-config, hot reloading in the example project.
- Small, non-breaking changes to the API.
https://github.com/parkerziegler/reason-urql/compare/v0.1.0-beta...v0.1.0
This is the initial beta release of reason-urql! These bindings are currently untested and should not be used in production just yet. Come help us by writing tests, opening issues, and filing PRs. Thanks!