🌟 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.