Skip to content

Commit 4ee53db

Browse files
author
parkerziegler
committed
Prepare v3.0.0.
1 parent ac8f69e commit 4ee53db

File tree

3 files changed

+116
-2
lines changed

3 files changed

+116
-2
lines changed

CHANGELOG.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,117 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.0] - 2020-11-14
9+
10+
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.
11+
12+
### Changed
13+
14+
- `urql`, along with its own `peerDependencies`, should be installed alongside `reason-urql`, which no longer bundles `urql` as a direct dependency. See updated installation instructions in the README. PR by @parkerziegler [here](https://github.com/FormidableLabs/reason-urql/pull/224).
15+
- Users should install `@reasonml-community/graphql-ppx` as a `peerDependency` of `reason-urql`.
16+
- Users depending on `bs-platform>=8.0.0` will need to specify a resolution for `wonka` v5 using [yarn resolutions](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/). See updated installation instructions in the README.
17+
- `Client.execute*` methods underwent four major API changes:
18+
19+
1. There is no longer a `~request` labelled argument. Instead, the GraphQL operation is passed using `~query` for `Client.executeQuery`, `~mutation` for `Client.executeMutation`, and `~subscription` for `Client.executeSubscription`. This applies to `Client.query`, `Client.mutation`, `Client.subscription`, and `Client.readQuery` as well.
20+
2. GraphQL operations are passed as [first-class modules](https://dev.realworldocaml.org/first-class-modules.html) to `Client.execute*` methods. This means you pass your entire GraphQL query `module` as a function argument, like so:
21+
22+
```reason
23+
open ReasonUrql;
24+
25+
module GetAllDogs = [%graphql {|
26+
query getAllDogs {
27+
dogs {
28+
name
29+
breed
30+
likes
31+
}
32+
}
33+
|}];
34+
35+
/* Pass GetAllDogs as a first-class module to Client.executeQuery. */
36+
Client.executeQuery(~query=(module GetAllDogs), ())
37+
```
38+
39+
3. Variables are passed as the last positional argument to `Client.execute*` methods, if they are required. PR by @parkerziegler [here](https://github.com/FormidableLabs/reason-urql/pull/226). We interface with `@reasonml-community/graphql-ppx` to typecheck your `variables` 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:
40+
41+
```reason
42+
open ReasonUrql;
43+
44+
module GetDog = [%graphql {|
45+
query getDog($key: ID!) {
46+
dog(key: $key) {
47+
name
48+
breed
49+
likes
50+
}
51+
}
52+
|}];
53+
54+
/* Pass GetDog as a first-class module to Client.executeQuery,
55+
with required variables as a record in the final position. */
56+
Client.executeQuery(~query=(module GetDog), {key: "12345"})
57+
```
58+
59+
4. The `response` variant for `Client.execute*` methods was renamed to `operationResponse` and should be referenced from the `Types` module rather than the `Client` module.
60+
61+
- The hooks APIs underwent three major API changes:
62+
63+
1. There is no longer a `~request` labelled argument. Instead, the GraphQL operation is passed using `~query` for `useQuery`, `~mutation` for `useMutation`, and `~subscription` for `useSubscription`.
64+
2. GraphQL operations are passed as [first-class modules](https://dev.realworldocaml.org/first-class-modules.html) to each hook. This means you pass your entire GraphQL query `module` as a function argument, like so:
65+
66+
```reason
67+
open ReasonUrql;
68+
69+
module GetAllDogs = [%graphql {|
70+
query getAllDogs {
71+
dogs {
72+
name
73+
breed
74+
likes
75+
}
76+
}
77+
|}];
78+
79+
[@react.component]
80+
let make = () => {
81+
/* Pass GetAllDogs as a first-class module to useQuery. */
82+
let (Hooks.{response}, _) = Hooks.useQuery(~query=(module GetAllDogs), ());
83+
84+
/* Return the JSX for your component. */
85+
}
86+
```
87+
88+
3. Variables are passed as the last positional argument to a hook, if they are required. PR by @amiralies [here](https://github.com/FormidableLabs/reason-urql/pull/225). We interface with `@reasonml-community/graphql-ppx` to typecheck your `variables` 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:
89+
90+
```reason
91+
module GetDog = [%graphql {|
92+
query getDog($key: ID!) {
93+
dog(key: $key) {
94+
name
95+
breed
96+
likes
97+
}
98+
}
99+
|}];
100+
101+
[@react.component]
102+
let make = () => {
103+
/* Pass GetDog as a first-class module to useQuery,
104+
with required variables as a record in the final position. */
105+
let (Hooks.{response}, _) = Hooks.useQuery(~query=(module GetDog), {key: "12345"});
106+
107+
/* Return the JSX for your component. */
108+
}
109+
```
110+
111+
### Removed
112+
113+
- The `useDynamicMutation` hook was removed. `useMutation` now consolidates the former use case for this hook and brings our APIs more inline with how `urql` works.
114+
115+
### Diff
116+
117+
https://github.com/FormidableLabs/reason-urql/compare/v2.1.0...v3.0.0
118+
8119
## [3.0.0-rc.0] - 2020-11-12
9120

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

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@ Reason bindings for Formidable's Universal React Query Library, [`urql`](https:/
2828

2929
## 💾 Installation
3030

31-
### 1. Install `reason-urql` and its `peerDependencies`.
31+
### 1. Install `reason-urql` alongside its `peerDependencies` and `devDependencies`.
3232

3333
```sh
3434
yarn add reason-urql urql graphql
35+
yarn add gentype --dev
3536
```
3637

3738
We try to keep our bindings as close to latest `urql` as possible. However, `urql` tends to make releases a bit ahead of `reason-urql`. To get a compatible version, we recommend always staying strictly within this project's `peerDependency` range for `urql`.
3839

40+
The `gentype` `devDependency` is a requirement introduced by `urql`'s use of `wonka`. `wonka`'s source uses `@genType` declarations, so when the BuckleScript / ReScript compiler attempts to compile `wonka` in your project, it'll need a local copy of `gentype` to use.
41+
3942
#### 1a. **Important note for users of `bs-platform>=8.0.0`**.
4043

4144
If using `bs-platform>=8.0.0` you'll need to use [`yarn resolutions`](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/) to specify a specific version of `wonka` to resolve. `urql` has an explicit dependency on latest `wonka` `v4`, which is incompatible with `bs-platform>=8.0.0`. See [this issue](https://github.com/kitten/wonka/issues/85) for more details.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0",
5252
"react": "^16.8.0",
5353
"reason-react": "^0.7.0",
54-
"urql": "~1.10.0"
54+
"urql": "~1.11.0"
5555
},
5656
"resolutions": {
5757
"wonka": "5.0.0-rc.1"

0 commit comments

Comments
 (0)