Releases: teamwalnut/rescript-urql
@urql/rescript
This release adds support for several major version upgrades of dependencies, including:
- Support for
[email protected]. - Support for
@rescript/react.reason-reactis no longer supported moving forward. - Support for
[email protected].
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/rescriptChanged
reason-urqlis now available as@urql/rescript. PR by @parkerziegler here.@urql/rescriptis now compatible with[email protected],[email protected], 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 in[email protected]. PR by @parkerziegler here. More information on this deprecation can be found in theurqlCHANGELOG.
Diff
🔎 Persisted Fetch and Refocus Exchanges
This release adds bindings for two additional ecosystem exchanges:
Added
- 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.
Diff
🔁 Retry and Request Policy Exchanges
This release adds bindings for two additional ecosystem exchanges:
Added
- 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.
Diff
🗂️ Multipart Fetch Support
This release adds a thin binding for @urql/exchange-multipart-fetch.
Added
- 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.
Diff
Migration to ReScript
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.
Changed
- 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.
Diff
🌟 v3
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.
Changed
-
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
Removed
- The
useDynamicMutationhook was removed.useMutationnow consolidates the former use case for this hook and brings our APIs more inline with howurqlworks.
Diff
First Release Candidate for v3!
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.
Diff
🦅 urql 1.10 Compatibility
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.
Diff
Binding to urql 1.10
This release fixes some important bugs identified in the v2.0.0 release.
Fixed
- 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.
Diff
🌟 v2
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.
Added
- 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.
Changed
- 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.Types.sourceT(UrqlClientTypes.operation)) =>
Wonka.Types.sourceT(UrqlClientTypes.operationResult);- Local binding of
graphQLErroris now a record type rather than a[@bs.deriving abstract]and has its own moduleGraphQLError.
Removed
- 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.