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-react
is 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/rescript
Changed
reason-urql
is now available as@urql/rescript
. PR by @parkerziegler here.@urql/rescript
is now compatible with[email protected]
,[email protected]
, and@rescript/react
. You must upgrade to@rescript/react
fromreason-react
to use v4.0.0. PR by @parkerziegler here.- The
pollInterval
API 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 theurql
CHANGELOG.
Diff
🔎 Persisted Fetch and Refocus Exchanges
This release adds bindings for two additional ecosystem exchanges:
Added
- Bindings for
@urql/exchange-persisted-fetch
and@urql/exchange-refocus
were added. Consumers ofreason-urql
will need to install@urql/exchange-persisted-fetch
to callClient.Exchanges.persistedFetchExchange
and@urql/exchange-refocus
to 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-retry
and@urql/exchange-request-policy
were added. Consumers ofreason-urql
will need to install@urql/exchange-retry
to callClient.Exchanges.retryExchange
and@urql/exchange-request-policy
to 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-fetch
was added. Consumers ofreason-urql
will need to install@urql/exchange-multipart-fetch
to 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
CombinedError
is 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 bundlesurql
as a direct dependency. See updated installation instructions in the README. PR by @parkerziegler here. -
Users should install
@reasonml-community/graphql-ppx
as apeerDependency
ofreason-urql
. -
Users depending on
bs-platform>=8.0.0
will need to specify a resolution forwonka
v5 using yarn resolutions. See updated installation instructions in the README. -
Client.execute*
methods underwent four major API changes:- There is no longer a
~request
labelled argument. Instead, the GraphQL operation is passed using~query
forClient.executeQuery
,~mutation
forClient.executeMutation
, and~subscription
forClient.executeSubscription
. This applies toClient.query
,Client.mutation
,Client.subscription
, andClient.readQuery
as well. - GraphQL operations are passed as first-class modules to
Client.execute*
methods. This means you pass your entire GraphQL querymodule
as 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-ppx
to typecheck yourvariables
based 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
response
variant forClient.execute*
methods was renamed tooperationResponse
and should be referenced from theTypes
module rather than theClient
module.
- There is no longer a
-
The hooks APIs underwent three major API changes:
- There is no longer a
~request
labelled argument. Instead, the GraphQL operation is passed using~query
foruseQuery
,~mutation
foruseMutation
, and~subscription
foruseSubscription
. - GraphQL operations are passed as first-class modules to each hook. This means you pass your entire GraphQL query
module
as 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-ppx
to typecheck yourvariables
based 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
useDynamicMutation
hook was removed.useMutation
now consolidates the former use case for this hook and brings our APIs more inline with howurql
works.
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
null
on thedata
field 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 theoperationContext
record 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
stale
flag is now returned on all results returned byreason-urql
hooks, 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
response
variant now has 5 constructors –Fetching
,Data(d)
,PartialData(d, e)
,Error(e)
, andEmpty
. You can read more about each of these here. - The
UrqlTypes
module is now justTypes
. - The
Exchanges
module is now a sub-module of theClient
module. OnceReasonUrql
is brought into scope it can be refrenced asClient.Exchanges
. ssrExchange
now acceptsssrExchangeParams
as its first labeled argument, notssrExchangeOpts
.ssrExchangeParams
is also a record type whilessrExchangeOpts
was a[@bs.deriving abstract]
. This brings it more in line withurql
's implementation.serializedResult
is 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
graphQLError
is now a record type rather than a[@bs.deriving abstract]
and has its own moduleGraphQLError
.
Removed
- Component bindings for
Query
,Mutation
,Subscription
, andSubscriptionWithHandler
were removed. Just use the hooks APIs! Client
methods forexecuteRequestOperation
,reexecuteOperation
,createRequestOperation
, anddispatchOperation
were removed. These are no longer inurql
's public facing API.